Posts Tagged ‘sample code’

Hello friends i have develop one new control YHCPickerView. This is most useful when you have thousands of records in you UIPickerView and if you are searching particular one record then you have scroll lots of the records and after hard work you will get your records. So i have made YHCPickerView only for you so that you don’t need to scroll much.

Let me give you an example. Suppose you have develop registration form in your iPhone/iPad app and you have Country field in your form. Now user want to select his country from 246 country name at that time you need to provide some search functionality so that user can select his country will less scrolling.

You can download sample code from here


In iPhone sdk when to store some value to NSUserDefaults then that values are visible from “/Library/Preferences/.plist” .So this is not safe because every one can read what ever you have store to NSUserDefaults. It is very important when you want to store username and password or some secure information.
To provide security to you NSUserDefaults value i have some trick for you.
You can also store UIColor to NSUserDefaults by using NSKeyedUnarchiver.

//Store to USUserDefaults

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSData *txtData = [NSKeyedArchiver archivedDataWithRootObject:@"simpleText"];
NSData *textFeildData = [NSKeyedArchiver archivedDataWithRootObject:txtPassword.text];
NSData *colorData = [NSKeyedArchiver archivedDataWithRootObject:txtPassword.textColor];
[defaults setObject:colorData forKey:@"textColor"];
[defaults setObject:txtData forKey:@"simpleText"];
[defaults setObject:textFeildData forKey:@"textFeildData"];

[defaults synchronize];

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSData *txtData = [defaults objectForKey:@"simpleText"];
NSData *textFeildData = [defaults objectForKey:@"textFeildData"];
UIColor *color = [NSKeyedUnarchiver unarchiveObjectWithData:colorData];
NSString *strSimpleText = [NSKeyedUnarchiver unarchiveObjectWithData:txtData];
NSString *strPassword = [NSKeyedUnarchiver unarchiveObjectWithData:textFeildData];