cocoa

Atomic, asynchronous HTTP file POST with sensible feedback?

Hello! I've just started development on Macs and have found Cocoa to be a useful and thoughtful framework, but its HTTP functionality has me puzzled. I have an NSURLConnection object to download a file from my webserver using the HTTP GET method. NSURLConnect's asynchronous connection is great, I get plenty of feedback, I get each chun...

Adding non-model nodes to an NSTreeController

I have an NSTreeController that manages an entity is a core data model and an NSOutlineView that displays this tree. I would like the tree to display some special nodes that do not correspond to entities in the underlying core data model. How would I go about doing that? Should I subclass NSTreeController? ...

Disable automatic selection of a row after as NSTableView is populated

I have two NSTableViews populated with Core Data that are linked using bindings. When a row is selected in NSTableView1, NSTableView2 is populated and the first row in it is selected. I have registered the NSArrayController that corresponds to NSTableView2 with KVO on its selectionIndex. This is so that when a row is selected in NSTab...

How do I get the inner/client size of a NSView subclass?

I am doing manual layouting for my Cocoa application and at some point I need to figure out what the inner size of a NSView subclass is. (E.g. What is the height available for my child view inside of a NSBox?) One of the reasons is that I am using a coordinate system with origin at the top-left and need to perform coordinate transformat...

Objective-C 2.0: class_copyPropertyList(), how to list properties from categories

I tried to list all properties of an Objective-C class like described in the Objective-C 2.0 Runtime Programming Guide: id LenderClass = objc_getClass("UIView"); unsigned int outCount, i; objc_property_t *properties = class_copyPropertyList(LenderClass, &outCount); for (i = 0; i < outCount; i++) { objc_property_t property = properti...

How do you put a normal control into an NSView?

What I'm actually trying to do is put a WebKitView into a ScreenSaver (which inherits NSView). I'm totally new to MacOS X and Cocoa (but I'm very familiar with Objective-C and used some parts of GNUStep). Do I need some laying out? I want to show only one control in the whole NSView. ...

NSTextView not refreshed properly on scrolling

Greetings, I have a NSTextView with a sizeable quantity of text. Whenever I scroll however, the view isn't updated properly. There are some artifacts that remain at the top or the bottom of the view. It appears that the view doesn't refresh itself often enough. If I scroll very slowly the view updates correctly though. If I add a border...

Property declaration for to-many relationships in Core Data

I have an application written using Core Data. I have 2 entities with a one-to-many relationship. I have subclassed NSManagedObject for both of them. The entity on the one-side is called Playlist and the other is called Song. The interface for Playlist: @interface VBPlaylist : NSManagedObject { } @property (readwrite, copy) NSStrin...

Key Value Observing in Cocoa, introspecting the change property

Hey all, I'm using key value observing on a boolean property an NSObject method: -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context The most interesting part of the value for this key path is a B...

How do I create a command line frontend for a GUI Cocoa app?

I'm creating a mainly GUI Cocoa app, but I want to create a command line front end as well that prints the same data so I can display it using geektool. I'm guessing I need to create an additional command line custom executable in my Xcode project and build it alongside the GUI executable? Is there a tutorial around for how to do this? ...

Do Cocoa NSSortDescriptors belong in the model or the controller?

Would NSSortDescriptor subclasses be placed in the Model or the Controller layer? Since they are primarily for display and business logic, it seems to make sense to put them in the Controller layer. But it also makes sense that models should know how to sort themselves. ...

Open Source Card Games or books for Objective-C/Cocoa?

I'm looking for open source projects for card games like Black Jack or Solitaire to get an idea on some GUI/Mac OSX desktop programming. I'm curious if anyone knows of any that're based on Objective-C/Cocoa that I can read/learn from? ...

Use an object after it has been released?

I am going through Cocoa Programming for Mac OS X by Aaron Hillegrass and have come to something I do not understand. On page 150-151 he creates an object, releases it, and then uses it again. For example: - (void) someMethod { NSMutableArray *array = [[NSMutableArray alloc] init]; NSString *str = [[NSString alloc] initWithStrin...

Cocoa Autoreleasing in loops

(I have read Apple's memory management guide, as well as other memory management help here, but am still confused on the following) What should I do for memory management with convenience methods in a loop? Do I need to explicitly create an autorelease pool and then drain it. Or is it all automagic? e.g. for (i=0; i<numFilePaths; i++...

How would you add a Group Feature like iChat's to your Core Data App?

I am Developing A Core Data App, and would like to add a feature like the Groups feature in iChat to my App. The Feature would be displayed in the table with normal table rows and more groups could be created. Other rows of the table could be dragged into the Group and the Group could be collapsed and opened. What code would I need to do...

Populate an NSTokenField with tokens from a container of objects

I have an NSTableView and an NSTokenField in a window. I have implemented the following delegate methods: tokenField:completionsForSubstring:indexOfToken:indexOfSelectedItem: tokenField:representedObjectForEditingString: tokenField:displayStringForRepresentedObject: I want to make it so that when a row is selected in it, the NSTokenF...

Loading a view on a background thread

Is it possible to load a view on a background thread? I am using buffering to render views into a buffer off screen so they can be scrolled into view later. I want to make the UI more response and it seems to be the off screen buffering that is the culprit, and am wondering if I can load up the buffered view on a background thread as I ...

Having trouble adding objects to NSMutableArray in Objective C.

I am using the iPhone SDK and have an issue doing something simple. I am trying to add an NSNumber object to an NSMutableArray instance variable. I tried adding NSNumber card to NSMutableArray viewedCardsArray, however without breaking, it does not get added to the array. Here is the code. //////////////////////////////////////////////...

Delegate methods of NSTextField using NSNotification

I have an NSTokenField in a window. I am using it to store tags related to a Core Data object. Right now I have it set up such that I can add tags to the objects, but I cannot delete them. I need a delegate method on the NSTokenField that can let me know when the user has moved the focus out of the NSTokenField. Since NSTokenField is...

How do I convert Cocoa co-ords from top left == origin to bottom left == origin

I use CGWindowListCopyWindowInfo to get a list of all windows. It gives me the co-ordinates of each window based upon the origin being the top-left of the screen. If I use NSWindow's setFrame method, the co-ordinates on based upon the origin being the bottom-left of the screen. What's a clean, reliable way to convert from one to the ot...