cocoa

How to get NSString (Unix style path) from FSSpec

Hi, I am in Mac. How to get NSString (Unix style path) from FSSpec Regards, Dhana. ...

[Obj-C] Mac Screensaver with WebView crashes

Hy everybody, I have a screensaver made with obj-c and cocoa. Everything works fine under OsX 10.6.2 except the following. Within my screensaver I have a WebView with some application running. When I try to call my objective-c app (the screensaver) via javascript, I get an error and the screensaver and the system preferences panel crash...

Accessing collection through KVC (to protect collection and be KVO compliant)

I have a class Test which has an array of Foos. I want to provide access to the Foos without exposing the ivar directly. I'm trying to make this KVC compliant (also to pave the way for KVO compliance). I have: Test.h @interface Test : NSObject { NSMutableArray *foos; } @property (readonly, copy) NSMutableArray *foos; @end Test....

Rewinding an NSInputStream based on an NSData

I have an NSData that I would like to read as an NSInputStream. This way I can have a consistent API for processing both files and in-memory data. As part of the processing, I would like to make sure that the stream begins with some set of bytes (if it doesn't, I need to process it differently). I'd like to avoid reading a whole file int...

Getting a Cocoa/Objective-C callback from Google Maps with WebView

Hi, all. I'm working on a new feature for my Mac application and it has to do with maps. As an example, let's use iPhoto's "Places". iPhoto uses Google Maps to show the location of various photos with red pins. Now when I click onto one of those pins, the application itself - iPhoto - reacts to that click, not the WebView / the map. So...

Can't create new xib files in Xcode projects

This one is a doozy... My buddy just downloaded the iPhone SDK on his Snow Leopard MacBook Pro. No matter what kind of project he creates (Window Based, View Based, etc...,) he can't create or use his own xib files. The project will compile and run fine until he adds a new xib file. Here are some symptoms: When he selects a pre-gener...

How to programatically setObjectClass for NSArrayController

I'm having a problem with what should be a very simple thing. I want to create an NSArrayController and specify the class it manages. Problem is, I can't figure out the correct way to specify the Class in the setObjectClass method. I want to do the following: [projectArrayController setObjectClass:SKHProject]; SKHProject is a class...

How to delay while retaining a responsive GUI on Cocoa Touch?

Basically, I have an array of buttons I want to iterate and highlight (among other things) one after another, with a delay in-between. Seems like an easy task, but I can't seem to manage to get it to work cleanly while still being responsive. I started out with this: for MyButton *button in buttons { [button highlight]; [button...

What's the difference between data source and delegate ?

I have a fundamental question related to Cocoa frameworks design patterns. What's the difference between delegate and data source? Both of them could use @protocols declaration, but some classes or frameworks are using delegate, and some others are using data source. All I can understand from UI/NSTableView is the delegate respond to ...

Waiting for a specified duration in Cocoa

Is there a more straightforward way to wait for a specific amount of time in Cocoa than what I have come up with below? - (void) buttonPressed { [self makeSomeChanges]; // give the user some visual feedback and wait a bit so he can see it [self displayThoseChangesToTheUser]; [self performSelector:@selector(buttonPressed...

Force NSMenu (nested submenu) update for Main Menu of Cocoa App

I have some submenu inserted as Window item submenu of Main Menu I have an instance of my object (let's assume its class name is MenuController) inherited from NSObject and supports 2 from NSMenuDelegate methods: – numberOfItemsInMenu: – menu:updateItem:atIndex:shouldCancel: This instance added as Blue-Object into NIB for awaking at run...

Finder-style UI for NSURL bookmarkData resolution with missing file?

I am using the new NSURL bookmark data API introduced in OS X 10.6 to store an "alias" to a file system resource. When I use +[NSURL URLByResolvingBookmarkData:options:relativeToURL:bookmarkDataIsStale:error:] to resolve the bookmark data, I get nil if the file no longer exists. Since I am not passing NSURLBookmarkResolutionWithoutUI...

NSObjectController confusion binding to a class property. Help!

Hi, I'm teaching myself cocoa and enjoying the experience most of the time. I have been struggling all day with a simple problem that google has let me down on. I have read the Cocoa Bindings Program Topics and think I grok it but still can't solve my issue. I have a very simple class called MTSong that has various properties. I have u...

How does CATransition work?

CATransition is quite unusual. Consider the following code. CATransition* trans=[CATransition animation]; trans.duration=0.5; trans.type=kCATransitionFade; [self.holdingView.layer addAnimation:trans forKey:nil]; self.loadingView.hidden=YES; self.displayView.hidden=NO; Notice that nowhere did I tell the transition that I wanted to disp...

Whats the appropriate way to react to the delete key in an NSOutlineView

I want to remove an item from my NSOutlineView when the user presses the delete key. Is the only way to do this to over-ride the keyUp method of NSResponder? I was hoping for higher level solution. ...

How to detect a gamepad button press on OSX 10.5 and higher?

How do I detect a button press on a USB gamepad on OSX 10.5 and higher? I can't wrap my head around the ridiculously complex HID Manager (even though apparently it was simplified with 10.5), and the code samples at Apple have thousands of lines of code that would take days to understand and isolate what I need, so I'd appreciate if some...

Which control is used as editor in mac mail - message body??

Hi all, I have a simple question: can anyone suggest me - what is the control which is used as editor to compose messages in mac mail?? My guess is- TextView but I cannot get - 1. How will I show icon in message body when some document is dragged and dropped in it, as in mac mail. Right now it only shows path of document! 2. How will...

Handling application exit in a Cocoa plug-in loaded into a Carbon application

I have a Cocoa plug-in that is loaded into an existing Carbon application. When the plug-in is first loaded, the Carbon application calls an initialization function, Plugin_Init() and in that function I set up the environment like so: //this is the global autorelease pool static NSAutoreleasePool* globalPool = nil; void Plugin_Init()...

String to int - cocoa, objective-c

I'm trying to get a value from a NSTextField (Label) and convert it to a int... minFormatter = [[NSNumberFormatter alloc] init]; [minFormatter setNumberStyle:NSNumberFormatterNoStyle]; NSNumber *minTimeValue = [minFormatter numberFromString:[NSString stringWithFormat:@"%@", [self.minTextLabel stringValue]]]; [minFormatter release...

How could I load each entity by category from a plist into a tableview?

My basic problem is I'm trying to populate a table view with selected entities from my plist using a 'category'. What would be the best approach to accomplish this? Would Core Data be a much friendlier data source? I'd rather not use Core Data, but I need something that works. Any suggestions would be greatly apprec! Basically, my p...