cocoa

Cocoa: [statusItem setView:myView] makes a white bar menu item no matter what

In my small app for Mac OS X I display some info in system menubar. I use statusItem = [ [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength] retain ]; It works very nice and I can change the text with [statusItem setTitle:[NSString stringWithString:@"Woo-hoo"]]; But it uses the default menu font ...

Objective C class definition confusion

I'm learning Objective-C through Cocoa (And loving it). I'm following a tutorial. Theres a class called Menu and the interface looks something like this. @interface Menu: MenuObject {} @end @interface MenuLayer : LayerObject {} -(void) someMethod:(id)sender -(void) someOtherMethod:(id)sender @end and the implementations follow the s...

SHA1 hashes not matching between my Rails and Cocoa apps

I have a Cocoa app send some data along with a SHA1 hash of that data to a Rails app which verifies that the data and the hash match, but they do not. To be sure I have logged hex versions of the data that is hashed to the console at both the Rails and Cocoa sides, and they match exactly. Here's the Cocoa part: #import <CommonCrypto/C...

How can I get notified of a system time change in my Cocoa application?

I have a Cocoa application that records datestamps on events. I need to know when the system time is reset and by how much, but I can't seem to fine a notification anywhere that tells me such a thing has happened. This change could happen because NTP reset the clock or because the user reset (e.g. from System Preferences). It would be gr...

Making an NSTextField act like a "microwave timer", store as NSNumber

What I'm trying to accomplish is two fold: I want my NSTextField to act like a "microwave timer" and update as characters are entered. So the field would default to "00:00" (minutes, seconds). When a 1 is pressed, the field would look like "00:01". Then a 4 is pressed and "00:14". A 2 is pressed and "01:42". I want to store this as an ...

Why would I make an all-optional message protocol?

I'm writing a Cocoa API for a project and the API takes a delegate. The protocol that I came up with declares all the methods as optional, but why would I do that instead of just documenting the delegate methods in a header file and taking a plain id as a parameter? ...

How are these two iPhone UI pieces accomplished?

This might be trivial for some of you, but I have two screenshots from the Lose It! app in which I'm curious how two different screens were put together. The first: http://dl-client.getdropbox.com/u/57676/screenshots/loseit1.jpg That middle graph which shows the statistics chart. Is that a custom image being drawn on top of with Core G...

Create a cookie for NSURLRequest?

I'm trying to send an authentication string via cookie in a NSMutableURLRequest. I'm trying to create the NSHTTPCookie through +(id)cookieWithProperties:(NSDictionary *)properties But nowhere have I been able to find how to specify the properties other than the simple key-value pair I have for authentication. When I only use my key-v...

Is there an iPhone equivalent of MAC_OS_X_VERSION_MIN_REQUIRED?

I would like to conditionally include code for an iPhone app depending on which version of the SDK I'm compiling against. On Mac OS X, there is the MAC_OS_X_VERSION_MIN_REQUIRED preprocessor macro which gets set to the value of the MACOSX_DEPLOYMENT_TARGET build setting by the compiler. Is there an equivalent on the iPhone? Update: I...

Cocos 2d & CGPoint confusion in Landscape Mode

Hi,all, me again with another noob Cocos2d iphone question. I've set my Director to Landscape, but when I was looking at the coordinates of the 'Touch Event' it was still picking them up as though the screen was portrait. So they were basically reversed. x = 100, y = 50 should have been x = 50, y = 100 No biggie, it was easily ...

Overwrite database or update (iPhone)?

I have a content based, read-only iPhone app. Users can select favorite topics, which I need to track. Some topics I'd like to make available between app updates through the App Store. I'll need to track if users have downloaded these particular topics or not until the App Store update is available. This approach will consist of two ...

How do I save current tab bar item when user quits and reload to that item when restart?

I want to save the current tab the user is in when he/she quits the application so I can load the application with that tab highlighted when the user re-enters the app. I presume I use the following method within my app delegate to save the current tab - (void)applicationWillTerminate:(UIApplication *)application but how do I gain acc...

Why do Cocoa apps use so much memory?

Even the standard blank-window Cocoa app that gets built when you make a new Cocoa project in Xcode uses almost 6 MB of memory. What's the reason for this? Is it possible to make an app use less, or does OS X simply manage memory differently for Cocoa apps? Not that I'm complaining. I know that performance "hardly matters anymore" (edit...

Gray NSTableView à la iTunes

How can I achieve the dark gray NSTableView look (used in iTunes, Delicious Library, etc.) in my own application? I always thought this was an option in NSTableView (or NSTableHeaderView) but I never tried actually doing it. After hours of searching, I'm pretty convinced that no such option exists, and that I need to do my own drawin...

Limiting the number of objects in NSArrayController

I'm trying to create some kind of "Top 25" list in my app. I've used NSPredicate to filter the contents of the array controller but I want to limit the number of the results to just 25 objects. How could I do that? ...

How to add data for NSOutputStream?

I want to convert a UIImage to an NSOutputStream and send it to a server through socket. #import "Connection.h" @implementation Connection -(void) open: (NSString *) h : (int) p { strHost = h; intPort = p; [NSStream getStreamsToHost:objHost port:intPort inputStream: [receiveStream retain]; [sendStr...

RubyCocoa, what's the point?

I was wondering what's the point of using Ruby (or even Python) in Cocoa application development other that not learning Objective-C (which is pretty simple language and will not take to more than few days to learn). I'm new to this and I'm interested why people do this? What are Pros and Cons. ...

iPhone Quartz2D: simple animation via delayed drawing

I'm trying to implement some very simple line drawing animation for my iPhone app. I would like to draw a rectangle on my view after a delay. I'm using performSelector to run my drawing method. -(void) drawRowAndColumn: (id) rowAndColumn { int rc = [rowAndColumn intValue]; CGContextRef context = UIGraphicsGetCurrentContext(); ...

Is there a way to use the WebKit web inspector from a Cocoa WebView object?

I would like to use the WebKit web inspector in a custom browser based on WebKit on OS X. Is it possible to use the web inspector on a webview object? If so, how? ...

NSString Compare Not Working in Objective-C

Following is Objective-C code where I'm trying to do a compare between two NSString values, however it throws a runtime error. Here's the code: NSDictionary *innerContent=[JSONResponseDict valueForKey:@"JSONRESPONSE"]; NSString *authFlag = [innerContent valueForKey:@"authenticationFlag"]; NSLog(@"authFlag = %@",authFlag); UIAlertView ...