cocoa

Cocoa switching a focus to my application

Hello, I have a statusbar application (the one that runs in the top bar of the system). When i click on the icon in the statusbar, a menu pops up and it has an item to configure my app. When i press this item, the main app window is shown [wndMain makeKeyAndOrderFront:self]; The problem is clicking a statusbar icon doesn't activate the ...

Dragging attachments out of NSTextView

Hi all, I am working on mac mail like feature- 1. dragging a file on body of message being composed and showing it as icon, over it. 2. dropping the icon of file from message body back to desktop or to any folder, so that it gets downloaded in it. I am able to implement the first point using NSTextView and calling method: -(void)setImp...

In Cocoa, what is the purpose of the main.m class?

It just sits there... How do I run code independently of UI actions (as in, not only in response to a button push)? I'm trying to initialize some objects and run some scripts BEFORE i awakeFromNib. How do I do this? ...

WebKit won't render on a layer backed view.

I have a simple NSView that hosts a WebView. When I try to make the view layer backed, the WebView stops rendering content - all it renders are the scroll bars. For simplicity, I added the following code to the applicationDidFinishLaunching method of the app delegate of a brand new xcode project :- NSView* view = [window contentView];...

what is this error message complaining about? and how to resolve it?

try to apply a patch and compile received warning message: <some_file>: In function '-[XXXXX saveAndCreate:]': <some_file>:262: warning: 'NSString' may not respond to '-stringByReplacingOccurrencesOfString:withString:' <some_file>:262: warning: (Messages without a matching method signature <some_file>:262: warning: will be assumed to re...

Cocoa/Objective-C : Best Practice to parse XML Document?

I never worked with XML in Cocoa before so I have no idea where to begin. Right now I need to parse a XML File (from Hard disc) into an object or even an Array of objects. My XML looks like this <Person> <FirstName> <LastName> etc... </Person> <Person> ... In my project I already have a Person class with a required propertie...

Cocoa/Objective-C : Load password protected webpage

I am looking for a Cocoa class that will enable me to load a web page (html source) from a given URL. To make things a bit more complicated I need to be able to set user name and password for this contention since the access to web page is restricted. ...

How to implement a button that functions like typing words in Cocoa with IMKits?

In fact, i am implementing a virtual keyboard for my input method with Input-method Kits (IMKits). How can i achieve this? Which functions i need to override? Appreciated for help. ...

Difference between + and - methods in Objective-c

What is the difference between methods that are declared with - and methods that are declared with + e.g - (void)methodname + (void)methodname ...

"Building a Text Editor in 15 Minutes" reference example not working

I am trying to work on NSDocument, so I tried the Building a Text Editor in 15 Minutes example in the Text System Overview reference. I did some changes to code which was suggested, such as used property and synthesize in place of declaring and defining accessor methods. I followed each step written in the reference but could not imple...

Responder chains for nil-targeted actions and events

Hi, Do events (i.e. -keyDown: and -keyUp:) follow the same responder chain as nil-targeted actions? Thanks. ...

Animation of NSImage gets lost after archiving it with NSKeyedArchiver

Following situation: I have an instance of my NSObject sublcassed object. One of it's properties is a NSImage. After instanciating the object I convert it with NSKeyedArchiver to data, send it over the network, unarchive it with NSKeyedUnarchiver and display the image in a NSImageView (setAnimates: YES). Until here there are no problems...

Doing 2 NSURLRequests after each other

Hello, I'm trying to do two NSURLRequests after each other. The second request is based on the results from the first one. My first request is working fine. I have set the delegate to self and I'm informed when when the request is finished (in the connectionDidFinishLoading method). My question is now, how can I do the second request a...

Confused by behaviour of NSBundle

Hi, I've a plist file that sits in a directory called Templates of my .app directory. This plist file is loaded thus without any problems: NSDictionary *sqlPropertyList = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:CH_PQ_QUERIES ofType:@"plist"]]; I created a .txt file in the same directory and t...

How To Get Xcode Interface Builder To Pop Up When I Click My NIB File?

Hi guys, I am at work and trying to make an application for my company in Xcode, however when I click the Nib file I cannot get the interface builder to pop up. I am on a Mac that has lockdown control on it, and I am wondering if this is affecting my development environment? When I double-click the Nib file nothing happens. It just modal...

Implementing Find-Or-Create During Core Data Flat File Import

I am importing a large plist/XML into Core Data. The structure is simple: let's say there is Person and Company, and a Company can have many Persons. The import goes successfully, but the plist has no established relations, so duplicates of Company are inserted every time multiple people have the same Company. A potential solution lies ...

Need to do the opposite of NSSelectorFromString()

In Cocoa, you can write @selector(mySelectorNameWithObject:) to get a compiled SEL, or at runtime, NSSelectorFromString(@"mySelectorNameWithObject:") with return a SEL. According to Apple documentation: The only thing that makes the selector method name different from a plain string is that the compiler makes sure that selectors are ...

NSImage color shift on Snow Leopard

My app creates NSImages by compositing various other NSImages together. The original images are loaded from files using [NSBitmapImageRep imageRepWithContentsOfFile:]. The final image is then displayed on the screen. A few 10.6 customers have reported that the image they see (sometimes) has shifted colors. Specifically, all of the brigh...

How do I safely access the contents of an NSArray property from a secondary thread?

I have an app (using retain/release, not GC) that maintains an NSArray instance variable, which is exposed as a property like so: @interface MyObject : NSObject { NSArray* myArray; } @property (copy) NSArray* myArray; @end I want to access the contents of this array from a secondary thread, which is detached using -performSelector...

When do you use * in variable definitions (in Objective-C)?

Hi there, I'm still getting confused by Objective-C. Sometimes you declare a variable like so: NSRect rect; And sometimes like so: NSValue *value; I never know when to add the *, so far I always looked it up in Apple's documentation. I know the difference is between a value and a pointer to an object. But are there any hard and ...