This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (UIImage *)imageFromImage:(UIImage *)image inRect:(CGRect)rect { | |
| CGImageRef sourceImageRef = [image CGImage]; | |
| CGImageRef newImageRef = CGImageCreateWithImageInRect(sourceImageRef, rect); | |
| UIImage *newImage = [UIImage imageWithCGImage:newImageRef]; | |
| CGImageRelease(newImageRef); | |
| return newImage; | |
| } | |
| If you have implemented that function above. You can crop images using the code below (crop the image "whoeImage.png" to a rectangle (0,0,40,40)). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NSLog(@"%s", __FUNCTION__); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary]; | |
| NSLog(@"Bundle Info: %@", infoDictionary); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| UIColorSystemColors has these values to choose from. | |
| @interface UIColor (UIColorSystemColors) | |
| + (UIColor *)lightTextColor; // for a dark background | |
| + (UIColor *)darkTextColor; // for a light background | |
| + (UIColor *)groupTableViewBackgroundColor; | |
| + (UIColor *)viewFlipsideBackgroundColor; | |
| + (UIColor *)scrollViewTexturedBackgroundColor __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_3_2); | |
| + (UIColor *)underPageBackgroundColor __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_5_0); | |
| @end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Basic Array Sort In Ascending Order. | |
| [SomeArrayName sortUsingSelector:@selector(compare:)]; | |
| OR | |
| SomeArrayName = [SomeArrayName sortedArrayUsingSelector:@selector(compare:)];Sorting In Descending Order | |
| Sorting In Descending Order. | |
| NSSortDescriptor *sortOrder = [NSSortDescriptor sortDescriptorWithKey: @"self" ascending: NO]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Use [[NSBundle mainBundle] resourceURL] to gain a URL string of your local resource. | |
| For example you have index.html in you bundle resource directory. To create an NSURL of that local html file to display on your UIWebView. Simply do this. | |
| NSString *resourceURLString = [[NSBundle mainBundle] resourceURL]; | |
| resourceURLString will return something like this: file:/../AppName.app/ | |
| NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@index.html",resourceURLString]]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Add first all required framework to gain access of your device Address Book. | |
| AddressBook.framework and AddressBookUI.framework | |
| Then import these framworks to your controller. | |
| #import <AddressBook/AddressBook.h> | |
| #import <AddressBookUI/AddressBookUI.h> | |
| There are two ways to get your contacts. First is use the ABPeoplePickerNavigationController, the other is to use the ABAddressBookRef. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for (UIView *myView in MainView.subviews) { | |
| [myView removeFromSuperview]; | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Check first if PLIST exist | |
| NSArray *myPath = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES); | |
| NSString *documentsDirectory = [myPath objectAtIndex:0]; | |
| NSString *myPlistPath = [documentsDirectory stringByAppendingPathComponent: [NSString stringWithFormat: @"%@.plist", plistName] ]; | |
| [myPlistPath retain]; | |
| // If it's not there, copy it from the bundle | |
| NSFileManager *fileManger = [NSFileManager defaultManager]; | |
| if ( ![fileManger fileExistsAtPath:myPlistPath] ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Create Thread | |
| [NSThread detachNewThreadSelector:@selector(myMethod) toTarget:self withObject:nil]; | |
| Create a selector method called by our thread | |
| - (void)myMethod { | |
| NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; | |
| // code here | |
| [pool release]; |