스토리보드는 TextField 3개, 버튼 2개로 구성하였다. ID/PWD를 받는 Textfield 각각 1개씩 그리고 저장 버튼, 불러오기 버튼, 불러오기 버튼을 눌렀을 때 ID와 PWD를 표시해줄 TextField 1개.


#import <UIKit/UIKit.h>


@interface ViewController : UIViewController


- (IBAction)BtnSave:(id)sender;

- (IBAction)BtnLoad:(id)sender;


@property (weak, nonatomic) IBOutlet UITextField *txtF_ID;

@property (weak, nonatomic) IBOutlet UITextField *txtF_Pwd;


@property (weak, nonatomic) IBOutlet UITextField *txtF_Load;


extern NSString* value;

@end



ViewController.m 파일의 소스 코드이다.


#import "ViewController.h"


@interface ViewController ()




@end


@implementation ViewController


- (void)viewDidLoad

{

    [super viewDidLoad];

    NSLog(@"[D] viewDidLoad");

    // Do any additional setup after loading the view, typically from a nib.

}



- (void)didReceiveMemoryWarning

{

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}



- (IBAction)BtnSave:(id)sender

{

    @autoreleasepool {

        

        NSLog(@"[D] BtnSave Clicked...");

//        NSString* tmpText = _txtF_ID.text;

//        NSString* tmpText2 = _txtF_Pwd.text;

//        NSLog(@"[D] ID: %@  Passwd: %@",tmpText, tmpText2);

//        NSLog(@"[D] ID: %@  Passwd: %@",_txtF_ID.text, _txtF_Pwd.text);

//        [dic setObject:_txtF_ID.text forKey: @"first"];

//        self.dic = [NSMutableDictionary dic];

//        [dic setString:tmpText forKey:@"First"];

//        _txtF_ID.text = [_txtF_ID.text stringByAppendingString:@"This is ID"];

//        NSLog(@"[D] Append to text: %@", [_txtF_ID.text stringByAppendingString:_txtF_Pwd.text]);

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

        [dic setObject:[_txtF_ID.text stringByAppendingString:_txtF_Pwd.text] forKey: @"first"];


//        NSString* str = [dic objectForKey:@"first"];

//        NSLog(@"[D] Dictionary contents: %@", str);


        NSLog(@"[D] Dictionary contents: %@", [dic objectForKey:@"first"]);

        

        [[NSUserDefaults standardUserDefaults] setObject:[dic objectForKey:@"first"] forKey:@"first"];

        [[NSUserDefaults standardUserDefaults] synchronize];


//        [[NSUserDefaults standardUserDefaults] setObject:dic forKey:@"first"];

//        [[NSUserDefaults standardUserDefaults] synchronize];


        

        id value = [[NSUserDefaults standardUserDefaults] objectForKey:@"first"];

        NSLog(@"[D] NSUserDefaults Contents: %@", value);

        

    } // end of autoreleasepool

    

}


- (IBAction)BtnLoad:(id)sender

{

    NSLog(@"[D] BtnLoad Clicked...");

    NSMutableDictionary* value = [[NSUserDefaults standardUserDefaults] objectForKey:@"first"];

//    NSMutableDictionary* value;

//    [value objectForKey:@"first"];

    NSLog(@"[D] Load NSUserDefaults Contents: %@", value);

    

    _txtF_Load.text = value;

}

@end


수없이 많은 노가다를 거치고 나서 data를 NSDictionary에 넣고 Userdefault로 저장한 후 다시 Userdefault로 data를 불러들이는 걸 할 수 있었다.

스토리보드상에서 TextField에 지워지는 회색 글씨를 띄우려면 attribute inspector 에서 PlaceHolder에 글씨를 써주면 된다. 


Posted by 知彼知己百戰不殆
,

====NSUserDefaults 값 저장====

1. int 값 저장

[[NSUserDefaults standardUserDefaults] setInteger:<int value> forKey:<key value>];

2. bool 값 저장

[[NSUserDefaults standardUserDefaults] setBool:<bool value> forKey:<key value>];

3. object 저장

[[NSUserDefaults standardUserDefaults] setObject:<object> forKey:<key value>];

4. 저장한 데이터 동기화(적용)

[[NSUserDefaults standardUserDefaults] synchronize];


====NSUserDefaults에 저장된 데이터 읽기====

1. int 값 읽기

int value = [[NSUserDefaults standardUserDefaults] integerForKey:<key value>];

2. bool 값 읽기

bool value = [[NSUserDefaults standardUserDefaults] boolForKey:<key value>];

3. NSString 값 읽기 (NSString 값 저장은 NSString 자체가 object이기 때문에 setObject를 이용하면 됨

NSString* value = [[NSUserDefaults standardUserDefaults] stringForKey:<key value>];

4. object 읽기
id value = [[NSUserDefaults standardUserDefaults] objectForKey:<key value>];


출처: http://stormaa.tistory.com/38

Posted by 知彼知己百戰不殆
,

Since you made an install of a new OS you probably don't have any more your private and public key that you used to sign your app in XCode before. You need to regenerate those keys on your machine by revoking your previous certificate and ask for a new one the iOS development portal. As part of the process you will be ask to generate a Certificate Signing Request which is where you seem to have problem.

You will find all u need there which consist of (from the official doc):

1.Open Keychain Access on your Mac (located in Applications/Utilities).

2.Open Preferences and click Certificates. Make sure both Online Certificate Status Protocol and Certificate Revocation List are set to Off.

3.Choose Keychain Access > Certificate Assistant > Request a Certificate From a Certificate Authority.

Note: If you have a private key selected when you do this, the CSR won’t be accepted. Make sure no private key is selected. Enter your user email address and common name. Use the same address and name as you used to register in the iOS Developer Program. No CA Email Address is required.

4.Select the options “Saved to disk” and “Let me specify key pair information” and click Continue.

5.Specify a filename and click Save.

For the Key Size choose 2048 bits and for Algorithm choose RSA. Click Continue and the Certificate Assistant creates a CSR and saves the file to your specified location.


출처: https://stackoverflow.com/questions/12126496/how-to-obtain-certificate-signing-request

Posted by 知彼知己百戰不殆
,