Cocoa – Notification on NSUserDefaults value change?

Spent all day looking for the answer, only to find it 10 minutes after asking the question… Came across a solution through Key-Value-Observing: [[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@”values.MyPreference” options:NSKeyValueObservingOptionNew context:NULL]; Or, more simply (per comment below): [[NSUserDefaults standardUserDefaults] addObserver:self forKeyPath:@”MyPreference” options:NSKeyValueObservingOptionNew context:NULL];

Implementing a 30 day time trial [closed]

This issue comes up repeatedly on the cocoa-dev mailing list and the consensus answer is always do the simplest thing possible. Determined hackers will break all but the most over-engineered solution. And they’re unlikely to pay for the software anyways. Go for the 80/20 solution: the easy solution that gets 80% effect for 20% effort. … Read more

Are “EXC_BREAKPOINT (SIGTRAP)” exceptions caused by debugging breakpoints?

Are “EXC_BREAKPOINT (SIGTRAP)” exceptions caused by debugging breakpoints? No. Other way around, actually: A SIGTRAP (trace trap) will cause the debugger to break (interrupt) your program, the same way an actual breakpoint would. But that’s because the debugger always breaks on a crash, and a SIGTRAP (like several other signals) is one type of crash. … Read more

Formatting NSDate into particular styles for both year, month, day, and hour, minute, seconds

this is what i used: NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; [dateFormat setDateFormat:@”yyyy-MM-dd”]; NSDateFormatter *timeFormat = [[NSDateFormatter alloc] init]; [timeFormat setDateFormat:@”HH:mm:ss”]; NSDate *now = [[NSDate alloc] init]; NSString *theDate = [dateFormat stringFromDate:now]; NSString *theTime = [timeFormat stringFromDate:now]; NSLog(@”\n” “theDate: |%@| \n” “theTime: |%@| \n” , theDate, theTime); [dateFormat release]; [timeFormat release]; [now release];

NSString to NSDate

You can’t invent format string syntax and expect it to work; you need to actually use a documented format. (Seriously, “MM” meaning “month”, “minute” and “GMT offset minutes” all at the same time?) As the documentation points out, the 10.4 formatters use Unicode format strings. Try “yyyy-MM-dd HH:mm:ss ZZZ” instead. Also, Objective-C source is ASCII. … Read more

Core Data vs SQLite 3 [closed]

Although Core Data is a descendant of Apple’s Enterprise Object Framework, an object-relational mapper (ORM) that was/is tightly tied to a relational backend, Core Data is not an ORM. It is, in fact, an object graph management framework. It manages a potentially very large graph of object instances, allowing an app to work with a … Read more