cocoa

InitWith Methods vs. Factory Methods

I'm picking up ObjC and Cocoa, which is also my first serious foray into programming in general. I'm having trouble with the differences between initWith methods, which are called on instances, and factory methods, which are called on classes. Firstly, why are they called "factory" methods, and is there a proper term for what I've dubb...

Access to the NIB window controls

I have inherited a new class from NSWindowController to implement windowDidLoad and then access to the NIB defined window controls: - ( void ) windowDidLoad { NSArray * controls = [ [ [ self window ] contentView ] subviews ]; int i; NSRunAlertPanel( @"windowDidLoad", @"", @"OK", NULL, NULL ); if( [ controls count ] == 0 ) ...

Does Cocoa provide a built-in method to convert a key into a 'set' property accessor?

Does Cocoa provide a built-in method to convert a key string into a properly-formatted set property accessor? i.e. "lineSpacing" -> setLineSpacing: For example: NSString * key = @"lineSpacing"; SEL selector = [key magicallyConvertIntoSetPropertyAccessor]; or even: NSString * key = @"lineSpacing"; SEL selector = NSSelectorFromString(...

Hidden [CIImage initWithImage:] method?

Is Apple declaring method [CIImage initWithImage:(CIImage*)] that I'm not aware of? The only method with that signature that I'm aware of is [CISampler initWithImage:]. But when I tried to provide my own method, the compiler warns me saying that the method already exists. Background: I'm trying to create a convenience method that conv...

When does a performSelectorOnMainThread call get executed?

If I use a performSelectorOnMainThread call inside a detached thread, when does the main thread execute the request? Does it do so immediately after it finishes the current main thread operation, or is there some other type of hierarchy that determines when the performSelectorOnMainThread call executes? ...

CATransition replaceSubView:with…is animating all views

Hi everyone, how can I make it so all of my view's subviews aren't animated here and only the currentPage's representedView and the newPage's represented view's? CATransition *transition = [CATransition animation]; [transition setType:kCATransitionPush]; [transition setSubtype:([self indexOfPage:currentPage] < [self indexOfPage:...

Custom NSScrollers having weird effect from Core Animation

Hi everyone, I am making custom NSScrollers for use in NSScrollView. But when any of the superviews of the NSScroller gets Core Animation enabled. I get this drawing issue that's a huge nuisance. Whenever i scroll into the corners of the scroll view the scrollers clip. But if a scroller starts out drawing in the corner, the scroller part...

Best Practice - NSError domains and codes for your own project/app

Hi all, There is a previous SO post regarding setting up error domains for your own frameworks, but what is the best practice regarding setting up error domains and custom error codes for your own project/app? For example, supposing you're working on a Core Data-intensive app with lots of validations, should you just stick with the "of...

Programmatically adding glyphs (delete key, backspace, space, etc) to menu item

It used to be that in Carbon you could use SetMenuItemKeyGlyph. What's the alternative under 10.6? Will I need to use undocumented goodness or...? Thanks ...

cocoa playing an mp3

Hello, Is there an easy way to load, play and control an mp3 file from cocoa? Tried googling it, but, as all things apple, i get messy results and have no idea where to start. As i understand, there's and NSSound, but it has lots of limitations and then there's CoreAudio, but it's very difficult. So can someone point me in a right direc...

Problem removing multiple objects from NSMutableArray iPhone SDK

I am having trouble removing objects from nsmutable array. Here it is. NSURL *url = [NSURL URLWithString:@"http://www.lockerz.com/dailies"]]; NSData *datadata = [NSData dataWithContentsOfURL:url]; NSString *removeForArray = [[NSString alloc] initWithData:datadata encoding:NSASCIIStringEncoding]; NSArray *theArray = [removeForArray co...

Layer-hosting view not displaying

I'm having trouble with a layer hosting view. This version of initWithFrame: works as expected (the view is filled black) providing 'Wants Core Animation Layer' is selected in Interface Builder: - (id)initWithFrame:(NSRect)frame { self = [super initWithFrame:frame]; if (self) { [self setWantsLayer:YES]; [[s...

Performance - structs in NSValue vs container object

In a situation where I need to save all data members in a NSDictionary, does it make more sense to put structs (custom types, or even scalars i.e. CGPoint) in my own wrapper (not NSValue), so I can avoid the overhead of encoding/decoding it every time I get or set the member? For large structs (16 floats) the savings is IMO significant....

Cocoa Key-Value Coding and inverse relationship properties

I'm trying to figure out if the KVC mechanisms provide any sort of help when dealing with relationship properties which are inverse relationships of each other. I'll use the contrived and standard Department/Employee example. @interface Department : NSObject { NSMutableArray *employees; } @property (retain) NSMutableArray *employe...

this class is not key value coding-compliant for the key managedObjectContext

Update! I've created a sanitized test program that illustrates the issue. Here you can view a PDF of exactly what I've done, and download a .zip of the project Update2! See the comment thread of Conceited Code below to understand more about this problem. Update: Added bounty, I'm looking for an explanation of what's actual...

How to activate Type 1 (.pfb, .pfm, .afm) font with Objective-C (Cocoa) on Mac?

How can I activate Type 1 font that is consisting of files like .pfb, .pfm etc. on Mac in Objective-C? I mean, only for my program, and not for the whole Mac (FontBook) - I just need to activate it, write a text and then deactivate. I tried ATSFontActivateFromFileReference, pointing it to any of these files - no luck. Googling didn't he...

Simulate random position mouse events in Cocoa

Hello. I want to build a very rough app which will simulate mouse clicks every 10th of a second at random places on the entire screen. I was thinking of building this in Cocoa/Obj-C. Can anyone point me in a direction of research? Regards. ...

Starting Mac Application development

Hi all, I am newbie to Mac Application Development.I am planning for an application having the features like de-fragmenting the mac ,parental controls, data backup etc... I do have some exposure to Objective C (Developed a small application for iphone) So please anyone could advice me regarding where to start,where to find best re...

CALayer, anchorPoint and layer hierarchy

Hi, I try to use the anchorPoint in a layer hierarchy to move a layer with its sublayers. Unfortunately the sublayer did not move together with the root layer. In a custom NSView is set up my layer hierarchy like in the following snippet. CALayer * rootLayer; rootLayer = [[CALayer layer] retain]; rootLayer.position = CGPointMake(...); ...

Compiling a PyObjC application for 10.5 (Leopard) into xcode 10.6 (Snow Leopard)

I'm trying to deploy on 10.5 a PyObjC (or Cocoa-Python) application developed on Xcode 3.2.X (Snow Leopard) which runs perfectly fine on 10.6 systems. The application doesn't launch on 10.5;it crashes at launch giving this error message (found on Crash Report): Dyld Error Message: Library not loaded: /System/Library/Frameworks/...