cocoa

Countdown Timer in Cocoa

Hi Everyone: I am wondering if there is some way that I can create a timer that countdown from a given time. For example, say I want this timer to last an hour. There will be a NSTextField that will show the time remaining (ex. 25 minutes), and will auto update every minute to the new value. And then, when an hour is finally passed, ...

KVC/KVO and bindings: why am I only receiving one change notification?

I'm seeing some quirky behaviour with Cocoa's KVC/KVO and bindings. I have an NSArrayController object, with its 'content' bound to an NSMutableArray, and I have a controller registered as an observer of the arrangedObjects property on the NSArrayController. With this setup, I expect to receive a KVO notification every time the array is ...

Cocoa String Question

I have a NSString and I want to write its value to a NSMutableString. Is this valid: NSString *temp = [NSString stringWithString:@"test"]; NSMutableString *mutable = temp; I ask because although this seems doable, I would think that this would assign both temp and mutable to the same address space. I have this question a lot when pa...

Cocoa Core Data - Background Thread

I have a core data application based on the default xcode template, I have the main UI which is used for viewing the data and then I have a background thread which is downloading/inserting/editing data. I figured when the application launches I can create two NSManagedObjectContext, one which the applications reads from and the other in...

Opening Files - Cocoa

How would I be able to open files from my application? For example, they type in the directory in a textfield called "inputBox" and they press the button open, to open the file. Thanks Kevin ...

Cocoa - Singleton object: Where to initialize member variables?

Hello people! I was wondering where is the best place to initialize members of the singleton class. I'm using Apple fundamental guide singleton implementation. Could you please pinpoint at what line the inits happen? The code is the following: static MyGizmoClass *sharedGizmoManager = nil; + (MyGizmoClass*)sharedManager { @synchr...

When do I not need to specify File's Owner for a nib?

I have been reading up on File's Owner here on Stack Overflow and a few other resources, but I was left with one question. When do I not need a File's Owner for a nib? In chapter 8 of Exploring the iPhone SDK (a great book by the way) you design a table view cell nib. The author says the following: You might be wondering why we're not d...

How to import JSON framework?

I've downloaded the JSON framework DMG from http://code.google.com/p/json-framework/downloads/list. I followed Option 3 here: http://code.google.com/p/json-framework/wiki/InstallationInstructions. For the copy files build phase, I set path to ~/Library/Frameworks/JSON.framework. Buid failed. I then tried setting it to my project root....

App crashes when updating an highlighted NSMenuItem

Heyho! I've a little app running as LSUIElement with a NSStatusItem. Sometimes the popupmenu's menuitems are updated by the code. But when the updated NSMenuItem (or its supermenu) is "highlighted" the app crashes without logging something. Do you have any idea? Thank you very much for your answers. ...

NSView leaves artifacts on another NSView when the first is moved across the second

I have an NSView subclass that can be dragged around in its superview. I move the views by calling NSView's setFrameOrigin and setFrameRotation methods in my mouseDragged event handler. The views are both moved and rotated with each call. I have multiple instances of these views contained by a single superview. The problem I'm having is...

Making an NSTableView Display Articles From An RSS Feed.

How would I make an NSTableView display an RSS Feed (just one)? I think it would have something to do with NSURL and Setting the Table Views Data Source. But how exactly would I do this? ...

How to draw my own key equivalents in NSMenuItem?

I would need something this owner drawn tab completition key equivalents in my own code. Like TextMate does in this example. I heared that the menu drawing is Carbon based but I don't hope it is such a huge hack. But whatever I tried and wherever I looked I couldn't find a clue. EDIT: I'm willing to accept even a carbon based answer,...

How to compare if two objects are really the same object?

I want to compare if an variable A represents the same object as variable B does. Could I do that with the == operator? Or what else is this exactly looking at? I think I need to check for the memory adress of the object where the variable is pointing to, right? ...

Encrypt resources in Cocoa app?

Hi, I have a shell script stored in the resources folder of my Cocoa app. If used improperly it could be dangerous (even though I have taken precautions to reduce exploits, such as using the absolute path to commands) so is there any way to encrypt the script in binary format, then decrypt it when it needs to be used? Thanks ...

Reading live output from shell script and updating progress bar

Hi, I have a shell script logging a list of numbers (1, 2, and so forth, one per line) to a log file. I need my ObjC app to read the log file every X seconds and then update my progress bar accordingly based on the last number logged in the log file. What's the best way to do this? ...

Is string formation optimized by the compiler?

I was trying to answer another question about the == operator and I created this code: NSString *aString = @"Hello"; NSString *bString = aString; NSString *cString = @"Hello"; if (aString == bString) NSLog(@"CHECK 1"); if (bString == cString) NSLog(@"CHECK 2"); if ([aString isEqual:bString]) NSLog(@"CHECK 3"); if ([aString isEqua...

Xcode App missing Cocoa Touch

In my Xcode App there is no Cocoa Touch. How do I fix that? What am I missing? ...

How to Rotate a CALayer-backed NSView subclass

I have a custom NSView subclass that I want to animate with Core Animation. I am already (without CA) setting the position and rotation of these views with NSView's setFrameOrigin and setFrameRotation methods. However, no matter what I do, once I add a layer backing to the views I can't get them to rotate. I've tried using NSView's setF...

Saving CGImageRef to a png file?

Hi, in my Cocoa application, I load a .jpg file from disk, manipulate it. Now it needs to be written to disk as a .png file. How can you do that? Thanks for your help! ...

How to change tint color of Cocoa's NSLevelIndicator?

Can the tint color of an NSLevelIndicator be changed at all? (setTintColor doesn't work) ...