cocoa

What's the optimum way of storing an NSDate in NSUserDefaults?

There's two ways of storing an NSDate in NSUserDefaults that I've come across. Option 1 - setObject:forKey: // Set NSDate *myDate = [NSDate date]; [[NSUserDefaults sharedUserDefaults] setObject:myDate forKey:@"myDateKey"]; // Get NSDate *myDate = (NSDate *)[[NSUserDefaults sharedUserDefaults] objectForKey:@"myDateKey"]; Option 2 - t...

How to sort model object by object in dictionary?

Hi, I've a model object that extends from NSObject called column. Column has two fields, properties and data. Properties is an NSDictionary that stores arbitrary key/value pairs while data is an array. Columns come in arrays and I need to sort them by a value I know will always be in properties, a value with the key ordinal_position. ...

Command Line Tools in Cocoa

I have created a simple command line tool that outputs "hello world". This is done in the main() function. In a separate application I can create a NSTask, pipe in the output from the hello world tool and use it successfully. What I need my command line tool to do, though, is output something every second (I'm simplifying this). Else...

What location do OSX/Cocoa applications generally use to store data files?

Do they write/store them within the app bundle/package itself? Or some other canonical location? Or does there not seem to be any standard? ...

Case insensitive NSPredicate for strings from an array?

I have a situation where I want to fetch objects from my core data store by the username key, but I want the comparison to be case-insensitive. The predicate I have is this: username IN $usernames I then do a variable substitution with an array of strings that are the usernames I want to find. It works but is case-sensitive. I'd like ...

Adding a detail record in a master-detail window view

I'll preface with "Brand new to Cocoa" -- I have a master/detail page on my app: Students that may have one or several contacts (i.e. parents, relatives, etc). I have a Student entity and a Contact entity with a relationship field called "contact" in the Student entity and another relationship field called "student" in the Contact enti...

NSOperationQueue not reusing thread on iPhone

I'm using iPhone SDK 3.1.2, and the following code shows the NSOperationQueue does not reuse the thread for each task. The code does not have any problems on Snow Leopard. - (void)applicationDidFinishLaunching:(UIApplication *)application { // Override point for customization after app launch [window addSubview:viewCon...

Hide NSWindow title bar

Is there a way to hide the titlebar in an NSWindow? I don't want to have to completely write a new custom window. I can't use NSBorderlessWindowMask because I have a bottom bar on my window, and using NSBorderlessWindowMask makes that disappear. I also tried using setContentBorderThickness:forEdge: with NSMaxYEdge and setting it to 0, th...

how to parse xml file with attributes?

I want to parse this file in Cocoa Application.but no parser for xml work well.Please help for parsing this file or other xml files like this. Thanks... My Xml File is as Under: Hiren <property id=\"license\"> <object> <property id=\"color\"> <string>red</string> </property> <property id=\"expiresOn\"> ...

How do I create an MD5 Hash of a string in Cocoa?

I know SHA-1 is preferred, but this project requires I use MD5. #include <openssl/md5.h> - (NSString*) MD5Hasher: (NSString*) query { NSData* hashed = [query dataUsingEncoding:NSUTF8StringEncoding]; unsigned char *digest = MD5([hashed bytes], [hashed length], NULL); NSString *final = [NSString stringWithUTF8String: (char *)...

NSInteger and decodeInteger:forKey: Problems.

I have the following two archiving methods: - (void) encodeWithCoder: (NSCoder *) encoder { [encoder encodeObject:self.exercises forKey:@"exercises"]; [encoder encodeObject:self.title forKey:@"title"]; [encoder encodeObject:self.description forKey:@"description"]; [encoder encodeInteger:self.idnum forKey:@"idnum"]; ...

Cocoa - Whats the best way for modifying NSOutlineView

Resuld shout be an settings panel with an OutlineView and "add item", "add group" and "delete" buttons. The buttons add entries to an NSOutlineView. The data is stored in a NSMutableDictionary (or whatever is suitable). Sorting/DragDrop enabled for the OutlineView . What is the best or most compfortable way for this (and write less code...

NSTextField value during edit is the field editors value. But I need the field's original value

When I send stringValue to a NSTextField when it's field editor is active, it returns the current value from the field editor. But I need the original value from the NSTextField before it started editing! How can I get it? (tried to get the stringValue from the NSTextFieldCell, but I get the field editors value too) Any suggestions how ...

How to get serial number from hard disks? "Mac"

Is there any easy way to get the serial number of all the hard disks in a Mac using any API's? Basically looking for a unique identifier for hard disk, with which I should make out that the Hard disk has been used(referred) by my application or not. Please let me know if there is any other solution. Note: I need this solution in 10.4 a...

how to get Device id, vendor id and product id of a mounted usb device in Mac OS cocoa

Hi I am trying to write a Cocoa program which detects iPods connected to Mac OS. I am listening to NSWorkspaceDidMountNotification and NSWorkspaceDidUnmountNotification for the USB device mount and unmount notifications. I can get the device path of the mounted device using NSString *path = [[notif userInfo] objectForKey:@"NSDevicePath"...

Drag & sweep with Cocoa on iPhone

Hi guys, I'm about to start a new iPhone app that requires a certain functionality but I'm not sure if it's doable. I'm willing to research but first I just wanted to know if I should at least consider it or not. I haven't seen this in an app before (which is my main concern, even though I haven't seen too many apps since I don't own a...

Implementing a 30 day time trial

Question for indie Mac developers out there: How do I implement a 30-day time trial in a non-evil fashion? Putting a counter in the prefs is not an option, since wiping prefs once a month is not a problem for an average user. Putting the counter in a hidden file somewhere sounds a bit dodgy - as a user I hate when apps sprinkle my hard...

NSSortDescriptor and nil values

I'm using an NSSortDescriptor to sort NSDate objects in an ascending order. However, I need nil dates to be at the bottom of the list, whereas at the moment they come at the top. ...

Can a WebKit-based Mac app use HTML5 databases from Safari?

I work on a WebKit-based app that "runs" several different web apps for a big telco client. Recent Safari versions are slower and slower to write out changes to the shared cookie cache and I am looking for alternatives to handing off a session from Safari to our client WebKit app. I'd like to use HTML5 database support found in newer Sa...

Can't add (Growl) Framework to Release version of my App

Hello everybody! I've created a new App and want to test ist in release Version. So I copied the Growl Framework to my ProjectFolder and added into XCode. Then I copied the new files in the Target to my Project and copied the growl.framework to the new "Copy Files" Framework folder in "Targets". When i debug my Project, its all right, ...