iPhone SDK Tips & Tricks
NSDate *now = [NSDate date];
int daysToAdd = 50; // or 60 :-)
// set up date components
NSDateComponents *components = [[[NSDateComponents alloc] init] autorelease];
[components setDay:daysToAdd];
// create a calendar
NSCalendar *gregorian = [[[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar] autorelease];
NSDate *newDate2 = [gregorian dateByAddingComponents:components toDate:now options:0];
NSLog(@"Clean: %@", newDate2);
Round Number
iPhone SDK Tips & Tricks
#import "math.h"
float numberToRound;
int result;
numberToRound = 4.51;
result = (int)roundf(numberToRound);
NSLog(@"roundf(%f) = %d", numberToRound, result); // roundf(4.510000) = 5
result = (int)ceilf(numberToRound);
NSLog(@"ceilf(%f) = %d", numberToRound, result); // ceilf(4.510000) = 5
result = (int)floorf(numberToRound);
NSLog(@"floorf(%f) = %d", numberToRound, result); // floorf(4.510000) = 4
#import "math.h"
float numberToRound;
int result;
numberToRound = 4.51;
result = (int)roundf(numberToRound);
NSLog(@"roundf(%f) = %d", numberToRound, result); // roundf(4.510000) = 5
result = (int)ceilf(numberToRound);
NSLog(@"ceilf(%f) = %d", numberToRound, result); // ceilf(4.510000) = 5
result = (int)floorf(numberToRound);
NSLog(@"floorf(%f) = %d", numberToRound, result); // floorf(4.510000) = 4
Remove or Delete User Default Data
iPhone SDK Tips & Tricks
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"dataName"];
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"dataName"];
Get iPhone Device Name, Unique Device Identifier (UDID), OS and Model
iPhone SDK Tips & Tricks
NSLog(@"uniqueIdentifier: %@", [[UIDevice currentDevice] uniqueIdentifier]);
NSLog(@"name: %@", [[UIDevice currentDevice] name]);
NSLog(@"systemName: %@", [[UIDevice currentDevice] systemName]);
NSLog(@"systemVersion: %@", [[UIDevice currentDevice] systemVersion]);
NSLog(@"model: %@", [[UIDevice currentDevice] model]);
NSLog(@"localizedModel: %@", [[UIDevice currentDevice] localizedModel]);
NSLog(@"uniqueIdentifier: %@", [[UIDevice currentDevice] uniqueIdentifier]);
NSLog(@"name: %@", [[UIDevice currentDevice] name]);
NSLog(@"systemName: %@", [[UIDevice currentDevice] systemName]);
NSLog(@"systemVersion: %@", [[UIDevice currentDevice] systemVersion]);
NSLog(@"model: %@", [[UIDevice currentDevice] model]);
NSLog(@"localizedModel: %@", [[UIDevice currentDevice] localizedModel]);
Labels:
iphone SDK,
properties,
uidevice
Subscribe to:
Posts (Atom)