This file contains 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
아이클라우드 이용 가능 여부 체크 (Checking for iCloud availability) | |
in application:didFinishLaunchingWithOptions method | |
id currentToken = [[NSFileManager defaultManager] ubiquityIdentityToken]; | |
if (currentToken) { | |
NSLog(@"iCloud access on with id %@", currentToken); | |
} else { | |
NSLog(@"No iCloud access"); | |
} |
This file contains 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
Subclassing UIDocument 심플 예제 | |
.h | |
@property (strong) NSString * noteContent; | |
.m | |
//Two override points, one when read and one when write. |
This file contains 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
iCloud Setup on AppDelegate | |
- (void)setupiCloud | |
{ | |
dispatch_queue_t background_queue = | |
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, | |
0); | |
dispatch_async(background_queue, ^{ | |
This file contains 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
아이폰과 아이패드의 인터페이스 오리엔테이션 | |
1. XCode -> View based application 생성 | |
2. ViewController -> UIImageView 삽입 | |
3. Resources 그룹에 임의의 이미지 삽입. 이 이미지를 UIImageView의 디폴트 이미지가 되도록 수정. | |
4. ViewController.m 파일의 shouldAutorotateToInterfaceOrientation: 메소드를 다음과 같이 수정. |
This file contains 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
distinction between an object and its class | |
//ice cream class | |
@interface IceCream : NSObject @property (nonatomic, strong) NSString *flavor; | |
@property (nonatomic, assign) int scoops; | |
- (void)eatIt; | |
@end | |
This file contains 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
Structs | |
//for example : | |
typedef struct { | |
CLLocationDegrees latitude; | |
CLLocationDegrees longitude; | |
} CLLocationCoordinate2D; | |
This file contains 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
Finding the Current First Responder | |
In iOS there is no simple call to retrieve the current first responder (without resorting to private APIs) | |
#import "UIResponder+FirstResponder.h" | |
static __weak id currentFirstResponder; | |
@implementation UIResponder (FirstResponder) |
This file contains 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
Directory Paths on the iPhone and iPad | |
//The correct way to retrieve the path of the documents directory in iOS is, according to Apple Documentation: | |
NSArray *arrayPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); | |
NSString *docDir = [arrayPaths objectAtIndex:0]; | |
//Objective-C class for the path of the documents directory | |
@interface Directories : NSObject { |
This file contains 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
Handy UIKit Debugging Functions | |
//before | |
NSLog(@"self.bounds (%g,%g,%g,%g)" | |
self.bounds.origin.x, | |
self.bounds.origin.y, | |
self.bounds.size.width, | |
self.bounds.size.height); | |
//after : handy string conversions functions in UIKit |
This file contains 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
assign and copy properties | |
Property with ’retain (or strong)’ attribute must be of object type | |
so, declare a property as assign if it has a primitive value | |
@property (nonatomic, assign) int someNumber; | |
You also use assign for structs, because they aren’t objects either | |
@property (nonatomic, assign) CLLocationCoordinate2D coordinate; |