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
//give object a unique numeric ID (itemId) | |
//ChecklistItem.h | |
@property (nonatomic, assign) NSInteger itemId; | |
//ChecklistItem.m | |
//initWithCoder - for view controllers that are automatically loaded from a nib or Storyboard | |
//for unfreezing the objects from the file | |
- (id)initWithCoder:(NSCoder *)aDecoder | |
{ |
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
- (void)textViewDidChange:(UITextView *)textView { | |
[self _showTextViewCaretPosition:textView]; | |
} | |
- (void)textViewDidChangeSelection:(UITextView *)textView { | |
[self _showTextViewCaretPosition:textView]; | |
} | |
- (void)_showTextViewCaretPosition:(UITextView *)textView { |
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 local notifications | |
#pragma mark - didFinishLaunchingWithOptions | |
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | |
{ | |
if (debug==1) {NSLog(@"Running %@ '%@'", self.class, NSStringFromSelector(_cmd));} | |
//local notifications test | |
NSDate *date = [NSDate dateWithTimeIntervalSinceNow:10]; |
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
//count items and update table views lable | |
//loops through the ChecklistItem objects from the items array | |
//If the item object has its checked property set to NO, increment the local variable count by 1 | |
//When looked at all the objects, return the value of this count to the caller | |
//Checklist.h | |
- (int)countUncheckedItems; | |
//Checklist.m |
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
//handleFirstTime | |
//in DataModel.m | |
- (void)registerDefaults { | |
NSDictionary *dictionary = @{ | |
@"ChecklistIndex" : @-1, | |
@"FirstTime" : @YES | |
}; |
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
//using basic NSDictionary | |
//inside DataModel.m | |
- (void)registerDefaults { | |
NSDictionary *dictionary = @{ | |
@"ChecklistIndex" : @-1, | |
@"FirstTime" : @YES //“FirstTime” acts as a boolean value because it’s either yes or no (true or false) | |
}; | |
[[NSUserDefaults standardUserDefaults] registerDefaults:dictionary]; |
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
//table view accessory-tapped delegate method | |
#pragma mark - Accessory-tapped 델리게이트 메소드 | |
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath | |
{ | |
if (debug==1) {NSLog(@"Running %@ '%@'", self.class, NSStringFromSelector(_cmd));} | |
UINavigationController *navigationController = [self.storyboard instantiateViewControllerWithIdentifier:@"ListNavigationController"]; | |
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
//dataModel using plist file and save to documents directory | |
#import "DataModel.h" | |
#import "Checklist.h" //first time runs the app then create a new Checklist object | |
@implementation DataModel | |
#define debug 1 | |
#pragma mark - 다큐먼트 디렉토리 |
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
//delegate pattern | |
//delegate pattern is commonly used to handle the following situation | |
//ex) | |
//screen A opens screen B and at some point screen B needs to communicate back to screen A, for example when it closes. | |
//The solution is to make A a delegate of B so screen B can send its messages to A whenever it needs to. | |
//Screen A launches screen B and becomes its delegate | |
//The cool thing about the delegate pattern is that screen B doesn’t really know anything about screen A. | |
//It just knows that some object is its delegate. Other than that, screen B doesn’t care who that is. Just like UITableView doesn’t really care about your view controller, only that it delivers table view cells when the table view asks for them. |
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
//Xcode Console Debug Code | |
#define debug 1 | |
if (debug==1) {NSLog(@"Running %@ '%@'", self.class, NSStringFromSelector(_cmd));} |