iPhone SDK Tips & Tricks
UIColor *myColor = [UIColor colorWithRed:32/255.0 green:93/255.0 blue:137/255.0 alpha:1.0];
iPhone SDK Tips & Tricks
iPhone SDK Tips & Tricks
NSDateFormatter *dateFormat = [[[NSDateFormatter alloc] init] autorelease];
[dateFormat setDateFormat:@"dd-MMM-yyyy"];
NSString *myString = [dateFormat stringFromDate:[NSDate date]];
iPhone SDK Tips & Tricks
#if !(TARGET_IPHONE_SIMULATOR)
NSLog(@"iphone");
#else
NSLog(@"simulator");
#endif
iPhone SDK Tips & Tricks
- (void)buttonClick:(id )sender{
NSLog(@"tag: %d", [sender tag]);
NSLog(@"title: %@", [sender currentTitle]);
}
iPhone SDK Tips & Tricks
NSDateComponents *compsDisplay = [[NSDateComponents alloc] init];
[compsDisplay setDay:25];
[compsDisplay setMonth:12];
[compsDisplay setYear:2012];
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDate *expDate = [gregorian dateFromComponents:compsDisplay];
[compsDisplay release];
int daysRemaining = [expDate timeIntervalSinceNow]/86400;
//minutes - divide by 60
//hours - divide by 3600
NSString *msg = [NSString stringWithFormat:@"%d days remaining.", dayRemaining];
- (void) webViewDidFinishLoad: (UIWebView *)sender
{
[self performSelector:@selector(calculateWebViewSize) withObject:nil afterDelay:0.1];
}
- (void) calculateWebViewSize
{
UIScrollView *webScrollView = [[myWebView subviews] objectAtIndex:0];
CGSize webScrollRect = webScrollView.contentSize;
NSLog(@"webScrollrect: %f", webScrollRect.height);
}To specify which OS version is the minimum that your application will support, you set the deployment target. Your application will then run on this minimum OS as well as all later versions.
source