Posts Tagged ‘iPhone’

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];

NSLog(@"%@\n%@",strSimpleText,strPassword);

Advertisements


iOS 6 has introduce new Social framework which is help to integrate all social sharing activity in you iPhone app. iOS 6 has also new UIActivityViewController which is used for social sharing as well as email, SMS, Save to Bookmark and many other options. Here is the sample code for Social framework as well as UIActivityViewController.


iOS hase come up with many new features. Here i will show demo of UICollectionView which is new control added to the iOS 6.

UICollectionView is something about GridLayou which is previous not available in iphone default control. But from iOS6 apple has introduce this new control. By using this control you can achieve functionality same as grideview. Also it’a very easy to understand if you have good knowledge of UITableView.

Basic requirements to develop this app.

  • Xcode 4.5
  • You can download sample code from here

    You must uncheck the box in your NIB that says “use auto layout” before you try to run this thing on a device that doesn’t support the new NSLayoutConstraint class.

    Now you can run your iPhone app in iOs 5.1.1 or below iOS though you have use xCode 4.5 Developer Preview.