cocoa

iTunes XML Parsing in cocoa

Hi all, I am developing an application in cocoa .I need to parse a iTunes XML file of large size(about 25Mb).I am using the following code snippet now NSDictionary *itunesDatabase = [NSDictionary dictionaryWithContentsOfFile:itunesPath]; But this is a little bit slow Is there any faster method to load the entire data to a dictiona...

Where to place the "Core Data Stack" in a Cocoa/Cocoa Touch application

In the iPhone Core Data Template, Apple places the Core Data Stack in the App Delegate. My initial inclination however is to move this code into it's own class whose responsibility is to handle the management of the Core Data Stack. Do you typically encapsulate this functionality within its own class or do you leave it in the App Deleg...

Editing an NSPredicate using NSPredicateEditor

I can create an NSPredicate easily using an NSPredicateEditor (a subclass of NSRuleEditor). What I'd like to know is this: How can I take an existing NSPredicate (one created by the editor) and reload it into the editor so that I can alter it? EDIT: I tried @John's suggestion of using setObjectValue:, but that didn't quite work. Let ...

When does application state belong in Core Data instead of NSUserDefaults?

I'm trying to decide whether some application state, specifically the selected item in a list, should be stored in Core Data or NSUserDefaults. Generally I believe that application preferences and state should persist in NSUserDefaults, and model-level data should persist elsewhere, say in Core Data. My model so far is: Should the dat...

What can cause Bonjour to not call me back during browsing?

I have a rather popular Bonjour-based application in App Store. It works perfectly, but around 0.2% of my users report a bizarre bug: "no arrows appear on the edges of the screen, so I can't share stuff with other people!". Needless to say, displaying these arrows is tied to the browsing of a particular Bonjour service on the local domai...

How to manually manage Core Data relationships when deleting

I have a Core Data entity, which contains a relationship to another entity. Under certain circumstances, I need to delete the managed objects in the relationship, and at other times no action needs to be taken. I have the Delete Rule on the entity is No Action because of this manual management. The problem I have is, where is the best...

Detecting multitouch iPhone-like "tap" on MacBookPro

After a period of iPhone work, I'm once again working on normal Cocoa apps on my MBP and I miss the "tap" gesture. I know that I can turn on the incredibly annoying "Tap to Click", feature in the Trackpad control pannel, but I don't want a click, I want a tap. I know it's probably not mac canon, but is it possible to receive this multi-...

3D CAD Graphics Framework on OS X - Suggestions?

I am looking to implement a 3D model viewer in my application. The application uses a series of interlinked plug-in objects, with user attributes, to contribute to the 3D form. (Basically a parametric design tool). The plug-ins must communicate via a common, simple, protocol as they may also be user contributed and so I am looking for ...

Can I trust Cocoa APIs not to fail silently, or do I have to defensively check everything?

Coming from a Symbian background, I'm somewhat concerned about the seeming lack of error handling in Cocoa. Cocoa has many methods that, as far as I can see, have no error reporting and yet could fail. Eg How come NSMutableString appendString has a void return type and doesn't throw exceptions (at least the documentation doesn't mentio...

HTTP Post Multipart/Form-Data to Rails from Desktop Client

I am trying to do an HTTP POST to create an instance of a model in my Ruby on Rails app from my Cocoa app. I am writing both the client (Cocoa) and server (Rails) so I can make changes in either location. I am running into a problem with the authentication token that is required when using Protect From Forgery All is fine when I can...

How do I make an NSView move to the front of all NSViews

Hi! How do I make an NSView window move up to the front. My app has 3 windows and when I press a button in one of them I want another to move on top of this one. ...

How to resize UIWebView content to specific dimensions?

Hello, I have an application requirement of displaying custom ads in it so I decided to use UIWebView and load specific url with 468x60 ads generated in it. It works like charm, except one thing: loaded ad is too big (naturally) for 320px iPhone screen and I am unable to force it to shrink a litle bit. What could I possibly do about it...

Formatted absolute value of an NSNumber

Well, it's actually the sum of an array of NSDecimalNumbers I'd like to get the absolute value of... I constantly feel like I'm fighting the framework with all the conversions & typecasting that are required...from double to NSNumber to NSDecimalNumber and back and...all while trying to maintain the precision that NSDecimalNumber affords...

Initialize a class only once

I have a class that contains a few instance methods which need to be called from another class. I know how to do that - TimeFormatter *myTimeFormatter = [[TimeFormatter alloc] init]; [myTimeFormatter formatTime:time]; However, I don't want to have to alloc and init TimeFormatter every time I need to call one of its methods. (I need t...

Easy way to get size of folder (ObjC/Cocoa) ?

Right now I'm using this code to get the size of a folder: NSArray *contents; NSEnumerator *enumerator; NSString *path; contents = [[NSFileManager defaultManager] subpathsAtPath:folderPath]; enumerator = [contents objectEnumerator]; while (path = [enumerator nextObject]) { NSDictionary *fattrib = [[NSFileM...

Can I force all links in a WebView (or WebFrame) to be treated as absolute paths?

So I'm working with WebKit's - WebView and WebFrame. I use a custom NSURLProtocol to retrieve the HTML for each request from a database. The problem arises from the fact that the links in the HTML are all relative, when they really ought to be absolute. For example, the page foo/bar.html May have a link in it that points to foo/baz.ht...

Objective C Code Explanation?

Hey guys, I had a question... I'm reading Cocoa Programming for Mac OSX and in Chapter 8 part 1, where he is writing the MyDocument.m file What does the line employees a; do? employees = [[NSMutableArray alloc] init]; is above, which means that employees is a mutable array, but I'm not sure what employees a; does. I'm just ta...

Find all Folders in Root Directory

Hi, I am developing an application in cocoa.I need to search all songs in selectyed folder.I used "subpathsAtPath" to get all the components in selected folder. This works fine if the user selects a particular folder like /User/Music.But if the user selects root directory like "/" then this method hangs .Is there any way to resolve this...

Change objects in NSUserDefaults without creating and re-setting copies

I've got dictionary stored in NSUserDefaults and I need to add/remove items in this dictionary. It bothers me that to do this I have to create mutable copy of entire dictionary, change one element and replace entire dictionary with new copy. copy = [[defaults objectForKey:@"foo"] mutableCopy]; [copy setObject:… forKey:@"bar"]; [default...

How Do I Comment A Core Data Schema?

I am new to Core Data, and am designing a schema. I would like to to comment things like: This what the field name means, and this is what it should contain Here is why we have this relationship This integer corresponds to this enum this field is in this encoding, or can only contain [a-zA-Z0-9-] I've read over the Xcode Entity Mode...