cocoa

How does an underscore in front of a variable in a cocoa objective-c class work?

I've seen in a few iPhone examples that attributes have used an underscore _ in front of the variable. Does anyone know what this means? or how it works? an interface file I'm using looks like: @interface MissionCell : UITableViewCell { Mission *_mission; UILabel *_missionName; } @property (nonatomic, retain) UILabel ...

How to create a horizontal scrolling view on iPhone???

I want to create a horizontal scrolling field at the top of a UITableView (something similar to what can be found on the Home section of the Facebook App). I want the scrolling field to be filled with six sections where only one section could be selected at a time? How should i do this? I know i should create a UIScrollView and set i...

How do I get the CoreData Debug argument to output to the console?

According to Apple documentation on debugging Core Data it says we should be able to pass an argument to the application which will output the SQL core data sends to SQLite. I have gone into the arguments tab of my executable in XCode and specified the argument: -com.apple.CoreData.SQLDebug 1 However, I see no SQL in the console. ...

Cocoa -/+ declarations

What's the difference between - and + when declaring with Cocoa/Obj-C. e.g. -(void)doSomething{} or +(void)doSomething{} ...

Replacing CMNewProfileSearch with non-deprecated, 64-bit code

I have existing code that uses CMNewProfileSearch to find then iterate over the color profiles on the system getting their names and full paths. Unfortunately, CMNewProfileSearch is deprecated in Mac OS X 10.5 and is also unavailable when compiling a 64-bit application. In reading the ColorSync Manager 2.5 Reference, it seems like the ...

iPhone Memory Management and Releasing

Here's a common practice I see often (including from a very popular iPhone developer book) In the .h file: @interface SomeViewController : UIViewController { UIImageView *imgView; } Somewhere in the .m file: imgView = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; [imgView setImage:[UIImage imageName...

Hide a window in cocoa from awakeFromNib

I have a NIB with two NSWindow objects. The controller class has two IBOutlets, one for each NSWindow (windowLogin and windowMain). I only want one of the windows visible on launch. Insdide awakeFromNib I am using: [windowMain orderOut:self]; which is having no effect. However, if I try: [windowMain setTitle:@"Renamed Title"]; ...

How can I subclass CALayer to return a pre-styled layer?

How do you subclass CALayer so that you return a layer with styling properties already set? So that: MyCustomLayer *layer = [MyCustomLayer layer]; would create a layer with these properties; layer.backgroundColor = sweetBackgroundColor.CGColor; layer.borderColor = sweetBorderColor.CGColor; layer.borderWidth = 2.0; layer.cornerRadiu...

How do you make a Menu Bar Item display how many rows there are in a table?

I have a core data table and would like the Menu Bar item to display how many rows there are in the table. I have already created the menu bar item using this code: -(void)applicationDidFinishLaunching:(NSNotification *)aNotification { NSStatusItem *statusItem = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItem...

Cocoa control for setting shorcuts

I want to build a preferences window for my Cocoa application. Is there a tutorial or example of how a control that sets shortcuts works? ...

Cocoa control for keywords/tags

I want to build a keyword/tag feature for my Cocoa application. Is there a tutorial or example of how a control that sets keywords/tags works? I want it to look something like the Keywords window in iPhoto that you get from Window->Show Keywords. ...

How do I save/export an OpenGL surface into Quicktime in Cocoa/Objective C?

i've modified the quartz composer slideshow sample from xcode to render a high speed slide show using a custom transition. The sample uses OpenGL (Cocoa) to render the slide show. I would like to export this slideshow into a video. Is there a way to use Cocoa/OpenGL to output this scene into a quicktime video? OR, should I just reimpl...

Determine if a path within an NSString is to a directory, or a file?

I have an NSString containing a path, but it could be either a file, or a directory. Is there an equivalent to the Python os.path.isdir() and os.path.isfile() methods in Cocoa? ...

How to limit NSTextField text length and keep it always upper case?

Need to have an NSTextField with a text limit of 4 characters maximum and show always in upper case but can't figure out a good way of achieving that. I've tried to do it through a binding with a validation method but the validation only gets called when the control loses first responder and that's no good. Temporarly I made it work by ...

Can I create properties with a public getter and private setter?

I'd like to use properties for my instance variables, but in many cases, I only want the class itself to have access to the setter. I was hoping I could do something like this: Foo.h: @interface Foo { NSString *bar; } @property (readonly) NSString *bar; @end Foo.m: #import "Foo.h" @interface Foo () @property (copy) NSString *bar...

How should I return an NSError object from a delegate method?

I'm designing a delegate method that is called when the remote server needs input from the delegate. The delegate at that point is responsible for filling in data to be sent to the server and also telling the server if there is an error at that point. The delegate method I have right now is: -(void)server:(MBServer*)server willSendDat...

Declare External Functions In A Cocoa / Obj-C Project.

Ok, here goes. I've completed a Cocoa foundation-tool that calculates mean absolute deviation of random integers (Just as a learning project). I've moved the calculation into a function called "findMeanAbsoluteDeviation()" It accepts a NSMutableArray of NSNumber objects to preform calculations. Anyways. So this works all fine and dandy...

Programmatic equivalent of "Visible at Launch" for NSWindows

I'm trying to write the programmatic equivalent of a nib file I've setup that contains two windows: a main window and sheet that appears after launch to prompt for credentials. Wiring these up in IB works fine, so long as one remembers to uncheck the "Visible at Launch" box on the sheet/window. However I can't figure out what the API eq...

Memory management when using macruby and Objective-C

Hi, i have a macruby application that leaks gigs of memory. Ruby is for the logic stuff and accesses some Objective-C classes of mine, to access functions like Accessibility-API and making some screenshots and process them via CIImage. Having ruby and Objective-C code, which one handles the memory? As far as i know, ruby collects its ...

Which method of checking to see if a NSDictionary contains a particular key is faster?

I can test for the presence of a key in an NSDictionary in two ways: BOOL containsKey = [[dictionary allKeys] containsObject:foo]; BOOL containsKey = ([dictionary objectForKey:foo] != nil); which method is faster? Please show your work. ...