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

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

- (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 닉네임영역
,
'Reachability.h',
'Reachability.m' 
파일을 인터넷에 찾아 참고 하시고 참고하시고

>>> SSID -> 아래 코드 참고하세요.

    NSArray * ifs = (__bridge_transfer id)CNCopySupportedInterfaces();
    
    for (NSString * item in ifs)
    {
        NSDictionary * info = (__bridge_transfer id)CNCopyCurrentNetworkInfo((__bridge CFStringRef)item);
        
        // kCNNetworkInfoKeySSID
        // kCNNetworkInfoKeyBSSID
        // kCNNetworkInfoKeySSIDData
        NSString * SSID = info[(NSString *)kCNNetworkInfoKeySSID];
       NSLog(@"SSID : %@", SSID);
    }


Posted by 닉네임영역
,

1. UITableView *tableView = (UITableView *)self.superview.superview;

    NSIndexPath *path = [tableView indexPathForCell:self];

    [tableView.delegate tableView:tableView didSelectRowAtIndexPath:path];


2. cell tag 연결 후 addTarget 하여 methhod 등록

Posted by 닉네임영역
,

1. NSUserDefaults : Dictionary 형태의 메모리 저장소

example>

// init

[NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

// get

[defaults objectForKey:@"Key"];

// set

NSDictionary *dictionary = [[NSDictionary alloc] initWithObjectsAndKeys:@"Key", @"Value", nil];

[defaults registerDefaults:dictionary];


2. CoreData : Database를 wrap 한 저장소

[Update 예정]


3. Sqlite : Database

[Update 예정]


4. Plist : DIctionary 형태의 파일 저장소

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

NSString *documentsDirectory = [paths objectAtIndex:0];

NSString *filePath = [documentsDirectory stringByAppendingString:@"/userInfo.plist"];

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

[plist setValue:@"Value" forKey:@"Key"];

[plist writeToFile:filePath atomically:YES];


5. Keychain : 폰 내부에 같은 도메인끼리 참조 할 수 있는 데이터 저장소


Posted by 닉네임영역
,

#define Appdelegate ((AppDelegate *)[[UIApplication sharedApplication] delegate])

Posted by 닉네임영역
,

 //iCloud 막을 Document경로 설정

    NSString *documentPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMaskYESlastObject];

    NSURL *pathURL= [NSURL fileURLWithPath:documentPath];

    

    NSLog(@"%@",documentPath);

    

    if([[[UIDevice currentDevicesystemVersionfloatValue] > 5.0f){

        [self addSkipBackupAttributeToItemAtURL:pathURL];

    }else{

        NSLog(@"CANNOT - CUZ VERSION IS UNDER 5.0.1");

    }



//밑으로 애플에서 알려준 코드 URL에 경로
그래서 위에서 5.0.1버전 부터 호출 하도록하고
경로를 설정.

//Cloud Data 백업 방지...

- (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL

{

    const char* filePath = [[URL pathfileSystemRepresentation];

    

    const char* attrName = "com.apple.MobileBackup";

    u_int8_t attrValue = 1;

    

    int result = setxattr(filePath, attrName, &attrValue, sizeof(attrValue), 00);

    return result == 0;

}


Posted by 닉네임영역
,

* 이렇게 싱글톤으로 안하고 직접 Prefix.pch에 바로 전역 선언으로 만들어 쓰는 방법도 있습니다. 


이제 선언했으니 함수에서 사용합니다.

@implementation Object

static Object *__sharedObject;

+ (Object *)sharedObject {

        if (__sharedObject == nil) {

                __sharedObject = [[Object alloc] init];

        }

        return __sharedObject;

}

@end

Posted by 닉네임영역
,
1. StoreKit.framework 라이브러리를 추가해줍니다 
2. 헤더파일에 #import <StoreKit/SKStoreProductViewController.h>를 추가합니다
3. SKStoreProductViewControllerDelegate 델리게이트를 추가해줍니다

[self presentAppStoreForID:[NSNumber numberWithInt:앱아이디inView:띄울 부모뷰(self.view) withDelegate:self withURL:[NSURLURLWithString:iOS6 이전 버전에 사용할 앱스토어 링크]];



- (void)presentAppStoreForID:(NSNumber *)appStoreID inView:(UIView *)view withDelegate:(id<SKStoreProductViewControllerDelegate>)delegate withURL:(NSURL *)appStoreURL

{

    if(NSClassFromString(@"SKStoreProductViewController")) { // iOS6 이상인지 체크


        SKStoreProductViewController *storeController = [[SKStoreProductViewController allocinit];

        storeController.delegate = delegate; // productViewControllerDidFinish


        NSDictionary *productParameters = @{ SKStoreProductParameterITunesItemIdentifier : appStoreID };



        [storeController loadProductWithParameters:productParameters completionBlock:^(BOOL result, NSError *error) {

            if (result) {

                [self presentViewController:storeController animated:YES completion:nil];

            } else {

                [[[UIAlertView allocinitWithTitle:@"연결 실패" message:@"앱을 불러올  없습니다." delegate:nil cancelButtonTitle:@"확인"otherButtonTitlesnil] show];

            }

        }];

    } else { // iOS6 이하일 

        [[UIApplication sharedApplicationopenURL:appStoreURL];

    }

}


// 닫을 때 

- (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController {

    [viewController dismissModalViewControllerAnimated:YES];

}


Posted by 닉네임영역
,

해당 버튼에 다음과 같이 옵션을 주면 됨.


self.btn.layer.borderWidth = 1.0f;

self.btn.layer.cornerRadius = 20.0f;

Posted by 닉네임영역
,

#define IS_4_INCH_DEVICE CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(320, 568)) || CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(568, 320))


#define ISRETINA ([[UIScreen mainScreen] respondsToSelector:@selector(scale)])?([[UIScreen mainScreen] scale] == 2.0):(0)


*.pch 파일에 붙여 넣기


if(IS_4_INCH_DEVICE) {

// 4inch

}

else {

// 3.5inch

}


if(ISRETINA) {

// 4inch

}

else {

// 3.5inch

}

Posted by 닉네임영역
,


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