cocoa

Programmatically Update an attribute in Core Data

I've looked through all the class documentation for Core Data and I can't find away to programmatically update values in a core data entity. For example, I have a structure similar to this: id | title ============ 1 | Foo 2 | Bar 3 | FooFoo Say that I want to update Bar to BarBar, I can't find any way to do this in any ...

SCM for Xcode?

I am developing an application for the Mac as a small team (me + another person) effort. We are located in different cities, and have started to see the need for solid source control management. None of us have any experience with this, and both of us are relatively new to Cocoa/Obj-C/Xcode (but do have C knowledge). Does anyone have a...

"stringWithString" vs "alloc ... initWithString ... autorelease" in Cocoa Objective-C.

I've seen it claimed that the following are "pretty much equivalent": foo([NSString stringWithString:@"blah"]) # version 1 foo([[[NSString alloc] initWithString:@"blah"] autorelease]) # version 2 Are the above in fact literally equivalent or are there any subtle differences? What are reasons to prefer one or th...

Returning a pointer to memory allocated within a function in Cocoa Objective-C.

In C, something like the following would be a disaster (ie, a memory leak) because you're returning a pointer to memory that you will never be able to free: NSString* foo() { return [NSString stringWithFormat:@"%i+%i=%i", 2, 2, 2+2]; } Is that in fact totally fine in Objective-C since the memory that the returned pointer points to w...

Porting WPF to Cocoa (and/or vice-versa)

I am in the beginning stages of creating software for a mISV-to-be. The program is a desktop application and in the long run I want to have a native version for both Windows and OS X (I have a looked at various cross-platform APIs, and none of them meet my needs). Initially though, I don't think it makes sense to develop for two platform...

initWithFrame not called, but awakeFromNib is

I am trying to subclass NSOutlineView. Here is my code: OutlineViewSublcass.h: #import <Cocoa/Cocoa.h> @interface OutlineViewSubclass : NSOutlineView { } @end OutlineViewSubclass.m: #import "OutlineViewSubclass.h" @implementation OutlineViewSubclass - (id)initWithFrame:(NSRect)frame { self = [super initWithFrame:frame]; print...

NSDictionary initWithContentsOfFile: messes up NSDecimalNumbers, why?

In my iPhone app I employ NSDecimalNumber to store some some currency rate values. I pull the data from the web the first time the app is launched and then again when they become obsolete, and I store them in a NSDictionary; then I use writeToFile:atomically:. When the app is launched for the first time, my rate conversion method works ...

Is there a way to get coordinates relative to the innermost NSView when the parent is not the window?

I have question about NSView: Imagine a Custom View where the mouseDown, mouseDrag and mouseUp methods are overriden so the user can drag a point (NSRect) on the screen. To drag it I need the mouse coordinates relative to the current view. This is not a problem when the parent of the view is the window, but how do I get them when the vi...

How to make a transparent NSView subclass handle mouse events?

The problem I have a transparent NSView on a transparent NSWindow. The view's drawRect: method draws some content (NSImages, NSBezierPaths and NSStrings) on the view but leaves parts of it transparent. Clicking on the regions of the view that have been drawn on invokes the usual mouse event handling methods (mouseDown: and mouseUp:). ...

What's the difference between Objective-C and Cocoa?

I'm just learning Objective-C/Cocoa programming for the Mac. All of the tutorials, books, blogs, podcasts, etc. I've been using really cover the two together. Is there an easy way to tell which pieces are vanilla Objective-C and which come from Cocoa? ...

How to open a launch NSWindow in Cocoa on a button click

I have an NSWindow that I defined in interface builder. I want to make it so that when the user clicks a button, it opens a new instance that NSWindow. Do I have to subclass NSWindow or something? ...

How can NSNotification be used to check a the status of an NSTask

How can NSNotification be used to check a the status of an NSTask? I know there are a couple of class methods inside the NSTask but don't really understand how to implement them in a Cocoa application. Can somebody help me? ...

Licensing Technology for OS X applications?

I've been looking at some OSX applications, and I noticed they all seem to have a similar (and slick) inbox purchase experience. Is there a third party thats providing this? If one wanted to implement it in ones own OS X application, where would one go? Examples include delicious library, things, the hit list, and coda. ...

How to give title to NSPersistentDocument window

I have subclassed NSPersistentDocument. I have renamed the window too. But when I run the application I get the title of the application window as "Untitled". There is no -setTitle: method which I can use to change the title. Any ideas how can I go about doing this? ...

Hiding the Keyboard

I have a UISearchBar and on the delegate method I hide the keyboard when the text field is cleared: - (void)searchBar:(UISearchBar *)filterBar textDidChange:(NSString *)filterText { NSLog(@"filter: %@", filterText); if ([filterText length] == 0) { NSLog(@"hiding keyboard"); [filterBar resignFirstResponder ]; N...

How can I access specific subsets of a large NSDictionary in Cocoa?

I have a single NSDictionary object which contains a large number of custom objects. The objects will either be of class B or of class C, both of which inherit from class A. If the objects are of type B, they will have an internal flag (kindOfCIsh) which will be used for future grouping. How can I, at different times in my program, get ...

How do I make the value binding of NSTokenField supply an NSString?

I have replaced an NSTextField with an NSTokenField so that I can perform some auto-completion. The value of the NSTextField was bound to a NSString attribute of a controller class. Now that I have changed the NSTextField to an NSTokenField the value has changed to an NSArray. How do I make the NSTokenField value binding be an NSString...

Techniques for implementing -hash on mutable Cocoa objects

The documentation for -hash says it must not change while a mutable object is stored in a collection, and similarly the documentation for -isEqual: says the -hash value must be the same for equal objects. Given this, does anybody have any suggestions for the best way to implement -hash such that it meets both these conditions and yet is...

How do you create hybrid XCode projects for Mac & iPhone?

Hello, I'm working on a project which shall contain two targets. One for building a Framework to use in Mac development and another to create a static library to use in iPhone development. In the common code it's no problem to #ifdef between the platforms, but I just can't get the targets and dependencies right. The first question is, ...

Data Store for a Mac/iPhone Hybrid App

I've been doing iPhone development for the last 5 months or so, and have been using Gus Mueller's FMDB for database interaction. My next project will have both a Mac and an iPhone application, and they will share data between them, although in the end, the iPhone will be mostly a viewer app, with some minor editing capabilities. My que...