Posts tagged snippet
Posts tagged snippet
1 note &
This is a simple method I use in all my apps to easily tell if the current device is iPad. I add the import for this class to the Prefix.pch file so I can easily check what device I am on without having to import.
//Device.h
@interface Device : NSObject
{
}
+ (BOOL) isPad;
@end
//Device.m
#import "Device.h"
@implementation Device
+ (BOOL) isPad
{
#ifdef UI_USER_INTERFACE_IDIOM
return UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad;
#endif
return NO;
}
@end
3 notes &
One thing I always wondered about Core Data is why the compiler would warn you if you didn’t specify the inverse relationship. After reading through Apple’s docs, they essentially say its to make your database more robust by reinforcing those relationships. Plus, you never know when you may have…
1 note &
This is a simple category that allows you to see if an instance of NSString contains a specific sub string.
@interface NSString (SubString)
- (BOOL) hasSubString:(NSString *) str;
@end
@implementation NSString (SubString)
- (BOOL) hasSubString:(NSString *) str
{
return [self rangeOfString:str].location != NSNotFound;
}
@end