cocoa

Updates to existing app

Hi, I have an App using sqlite. On first start, I copy the .db file into NSDocumentDirectory (so that I can make updates to it). In later versions, I plan to add new data to this database. How can I make sure, that with every application update (but not with every app start) the newest copy of this DB will be copied to NSDocumentDirecto...

Link to iTunes music

I would like to enable users to as simply as possible go to a certain music album in the iTunes music store (not the app store). Is it possible to create such a direct link that opens iTunes music store with particular music album or song? You can see such behavior in Shazam. ...

Is there a way to programmatically determine the proper sizes for Apple's built-in controls?

When writing Cocoa apps, I do the majority of the user interface layout programmatically. For example: NSRect popUpFrame = NSMakeRect(10, 10, 100, kDefaultPopUpButtonHeight); NSPopUpButton * popUp = [[NSPopUpButton alloc] initWithFrame:popUpFrame]; //... My question is about that kDefaultPopUpButtonHeight constant. I currently maintai...

How to get PDF chapter information with CGPDFDocumentGetCatalog?

Any sample code I can look at? ...

Drag-drop from NSTableView to NSImageView

Hi, I need to drag a row from NSTableView containing an image path and drop it over NSImageView, and the image of the dragged row should appear in the imageview. Help appreciated ...

How to find what day of the week for any given date using Cocoa

Hi, I'm trying to figure out what day (i.e. Monday, Friday...) of any given date (i.e. Jun 27th, 2009) Thank you. ...

How to do remote debugging from Leopard to Tiger?

I have an app that works great on Leopard but on Tiger I'm getting some errors I can't resolve just from the stack trace. Is it possible at all to do remote debugging from Leopard to Tiger, and if so, how? ...

How to display indeterminate NSProgressIndicator in the NSOutlineView?

I need to display a progress of loading of item's children. Please advise how to implement a progress indicator like it's done in Mail application: P. S. Here a source code of using indicator sub-views: http://snippets.dzone.com/posts/show/7684 ...

How to create a NSString from a format string like @"xxx=%@, yyy=%@" and a NSArray of objects?

Is there any way to create a new NSString from a format string like @"xxx=%@, yyy=%@" and a NSArray of objects? In the NSSTring class there are many methods like: - (id)initWithFormat:(NSString *)format arguments:(va_list)argList - (id)initWithFormat:(NSString *)format locale:(id)locale arguments:(va_list)argList + (id)stringWithForma...

Font size in pixels

On an iPhone how do I calculate the size of a character in pixels for a given point size? ...

Checking an empty Core Data relationship (SQLite)

I have a to-many relationship in my data model, and I'd like to get all the objects that have no corresponding objects in the relationship. For example: Customer -> Purchases I want to get all Customers that have 0 Purchases. I've read somewhere that I could use "Purchases[SIZE] = 0", but this gives me an unsupported function express...

CFReadStreamSetClient stops sending events at EOF

I have some code that downloads a file from the internet. Once I have written X bytes of that file to the local file system I tell another class to start reading it. CFReadStreamRef stream = CFReadStreamCreateWithFile(kCFAllocatorDefault, (CFURLRef)url); CFStreamClientContext context = {0, self, NULL, NULL, NULL}; CFReadStreamSetClient...

Retain a random number across different functions in Cocoa?

I know how to do a global variable, but whenever I try to define a global variable with a random number function, xcode says "initializer element is not constant." The compiler doesn't want to make a variable from a random number because the random number function is not constant. How do I generate a random number and then use that s...

objective-c question regarding NSString NSInteger and method calls

I like to create an instance of a custom class by passing it a value that upon init will help set it up. I've overridden init and actually changed it to: - (id)initWithValue:(NSInteger *)initialValue; i'd like to store this value in a property of the instantiated object and use the value to generate the filename of a UIImage that will...

How do I get the last HTTP Status Code from a UIWebView?

I would like to detect when a page load request give to a UIWebView has returned a status code in the 5xx or 4xx range. I've setup the delegate for the web view and have provided a -webView:didFailLoadWithError:error method but although it gets called fine for timeouts, it is not called for HTTP Status Code errors. Any suggestions? ...

Detect when app resigns active in cocoa?

Is there any way to detect when an app is no longer active? That is, listen for changes to this: [NSApp isActive] ...

Objective-C: What's the Difference between objectForKey and valueForKey?

What is the difference between objectForKey and valueForKey? I looked both up in the documentation and they seemed the same to me. ...

Enforcing that a class posts a particular NSNotification?

Is there any way to ensure that a class posts a particular NSNotification? (I have a set of classes, and I would like to enforce at compile-time (if possible) that the class posts a required NSNotification). Alternatively, if that is not possible, is there any workaround? ...

Persisting Currency format in Cocoa on a device that so easily could change Region Format

I'm storing my currency values in NSDecimalNumbers (as recommended in multiple other threads on this forum) and using an NSNumberFormatter to display them correctly and handle the text input. All good! However, when I change the Region Format under iPhone prefs General settings to somewhere outside the US, say Germany, and then look at m...

Equivalent of FileSystemWatcher (.NET) in Cocoa

Hai all, I am developing an application in Cocoa. I want to constantly check whether the contents of a file in a particular location is changed or not (like FileSystemWatcher in .NET). Please anyone give me a solution ...