외규장각 도서 환수 모금 캠페인

'2014/06'에 해당되는 글 2건

  1. 2014.06.09 WWDC 2014 swift
  2. 2014.06.03 image to md5 converting

따따디씨에서 새로운 언어(?)를 발표했다. 

스위프트란다.

기존 코드들에 대해 확 줄어들게 코딩할 수 있다던데 

오늘 맛좀 봤다.

머든지 그렇겠지만 익숙해지면 편할듯

유니코드 지원으로 변수명 한글이 된다.

변수명을 변수라고 해봤다. 잘된다...ㅋㅋㅋ


다만 아직은 xcode6 - beta라서 자동완성 기능이 원활하지 않다.

스토리보드도 해야 하는데 스위프트까지 ;;;;

간단한 tutorial을 링크를 참조 하시길


http://text.youknowone.org/post/87652586691/swift-list

https://www.penflip.com/jjuakim/swift-korean

Posted by 닉네임영역
,

////////////////////////////////////////////////////////////////////////////////////////////////////////////

- (NSMutableDictionary *)resourcesCheck {

    NSString* bundlePath = [[NSBundle mainBundle] bundlePath];

    NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:bundlePath];

    NSString *filePath;

    NSMutableDictionary *mArray = [[NSMutableDictionary alloc] init];

    

    while ((filePath = [enumerator nextObject]) != nil) {

        if (![[filePath pathExtension] isEqualToString:@"nib"]){

            NSString *path = [bundlePath stringByAppendingPathComponent:filePath];

            NSData *nsData = [NSData dataWithContentsOfFile:path];

            if (nsData)

                NSLog(@"%@", [nsData MD5]);

            [mArray setObject:[nsData MD5] forKey:filePath];

        }

    }

    

    return mArray;

}

////////////////////////////////////////////////////////////////////////////////////////////////////////////

#import "NSString+MD5.h"

 

@interface NSString(MD5)

 

- (NSString *)MD5;

 

@end

////////////////////////////////////////////////////////////////////////////////////////////////////////////

#import <CommonCrypto/CommonDigest.h>

 

@implementation NSString(MD5)

 

- (NSString*)MD5

{

// Create pointer to the string as UTF8

  const char *ptr = [self UTF8String];


  // Create byte array of unsigned chars

  unsigned char md5Buffer[CC_MD5_DIGEST_LENGTH];


// Create 16 bytes MD5 hash value, store in buffer

  CC_MD5(ptr, strlen(ptr), md5Buffer);


// Convert unsigned char buffer to NSString of hex values

  NSMutableString *output = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2];

  for(int i = 0; i < CC_MD5_DIGEST_LENGTH; i++) 

[output appendFormat:@"%02x",md5Buffer[i]];


  return output;

}

 

@end

////////////////////////////////////////////////////////////////////////////////////////////////////////////

#import "NSData+MD5.h"

 

@interface NSData(MD5)

 

- (NSString *)MD5;

 

@end

////////////////////////////////////////////////////////////////////////////////////////////////////////////

#import <CommonCrypto/CommonDigest.h>

 

@implementation NSData(MD5)

 

- (NSString*)MD5

{

  // Create byte array of unsigned chars

  unsigned char md5Buffer[CC_MD5_DIGEST_LENGTH];


// Create 16 byte MD5 hash value, store in buffer

  CC_MD5(self.bytes, self.length, md5Buffer);

    

// Convert unsigned char buffer to NSString of hex values

  NSMutableString *output = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2];

  for(int i = 0; i < CC_MD5_DIGEST_LENGTH; i++) 

[output appendFormat:@"%02x",md5Buffer[i]];


  return output;

}

 

@end

////////////////////////////////////////////////////////////////////////////////////////////////////////////


Posted by 닉네임영역
,


사랑합니다. 편안히 잠드소서