cocoa

How do I get each line from an NSString?

If I have an NSString with a text file in it, how do I get an NSArray of NSString with each NSString containing a line of the file. In 10.5 I did this: NSArray* lines = [str componentsSeparatedByCharactersInSet: [NSCharacterSet newlineCharacterSet]]; But that doesn't work in 10.4, and my program needs to work in 10.4. As well, it ne...

NSTextView not updating in a loop while writing to a USB device

I am writing an Objective-C application which communicates with a USB device. The application writes certain data to the device continuously and displays the status of the write operation in a textView, which is an object of NSTextView. I call the -[NSTextView insertText:] method in the loop when I get the write operation status from the...

Is Object Releasing on Program Exit Really Needed?

I have a technical question. This is NOT a question about proper coding. My question is TECHNICALLY is releasing objects on a programs exit/close needed? In other words, lets say for the sake of argument, you have a button that closes your application, but right before you close you display a image, and then you close the application. ...

How can I use Cocoa's Accessibility API to detect that a window is brought to front?

I'm using the Accessibility API to detect when a certain application opens windows, closes windows, when the windows are moved or resized, or made main and/or focused. However the client app seems to move a window to front without an Accessibility API notification being fired. How can my application detect when another application bring...

Encrypted web services connections and pk12 certificates

I need to make some code to talk to a SOAP web service. Unfortunately I'm unable to get a connection to the service as it requires a SSL connection encrypted with a special certificate. I've been given a pk12 certificate which when installed into my keychain allows me to access the SOAP service manually via Safari, but I'm unable to ge...

Setting the NSBrowserCell image using bindings?

I've got an NSBrowser hooked up to an NSTreeController bound to an array of NSTreeNode objects. It's easy enough to get the text portion working by setting the Content and Content Value bindings to properly reference the tree controller, but how do I set the image for each cell using bindings? ...

OS X inter thread communication question

I am developing a multi-threaded application in Cocoa. The main thread takes values from the user, and when a button is clicked I invoke a secondary thread in which a long calculation takes place. Now from this thread I have to return the output of every step of the calculation to the main thread. I want to periodically send data from on...

Programmatically Creating Controls in Cocoa

According to Cocoa Programming for Mac OS X, 3rd Edition, on page 245 (chapter 17), you will usually create views in Interface Builder. However, it is possible to create them in code, a la: NSView *superview = [window contentView]; NSRect frame = NSMakeRect(10, 10, 200, 100); NSButton *button = [[NSButton alloc] initWithFrame:frame]; ...

porting iPhone openGLES app to OSX?

Developing for the iPhone has been my first experience with objective-c and first in-depth experience with xcode. How difficult would it be to port an openGLES iPhone app to the OSX desktop using openGL? I am not asking about user interface - obviously there is no equivalent to cocoa touch UI on the desktop. I am asking specifically ab...

What's the difference between a CoreAnimation Layer Backed View and a Layer Hosting View?

What is the difference between a Layer Backed View and a Layer Hosting View in Core Animation? What are the steps to setting up each and when is it appropriate to use either type? ...

Using a NSMutableArray to store data

Can you store an Array ( that contains another two subarrays one being a string and another another array) into a single MutableArray object? ...

MouseUp and NSArrayController

How do you associate a -mouseUp: event with the -add: method of a NSArrayController? The -mouseUp: event lives in a different object but is #import'ed and instantiated in the object that holds the array being controlled. Usually, with an NSButton you command-drag from the button to the NSArrayController's -add: method but obviously thi...

How do I use NSScanner to parse a tab delimited string in Cocoa?

I have a web service which returns tab delimited data (see sample below). I need to parse this into an array or similar so I can create a navigation view of it. I've managed to perform the web request and could parse an XML file, but my knowledge of Objective-C is small. 433 Eat 502 Not Fussed 442 British 443 Chinese 4...

Design patterns for Apple's Cocoa frameworks: MVC, MVP, Passive View... where is Apple heading???

To lay the groundwork for this question, I'm going to state that I'm getting my definitions for MVC, MVP, and Passive View from the following: Model View Controller (MVC) Model View Presenter (MVP) Passive View (PV) Apple has always stated that it uses the MVC design pattern, but I noticed in OS X 10.5 we've gotten NSViewController, KV...

Changing Mac OS X User Password Programmatically or via Script

I need to be able to change a user's password from a cron task or from an ssh session. Is there an easy way to do that with a bash script? If not, what's the easiest way to do it in Cocoa? ...

Implementing a WebView database quota delegate

How do I implement this method (see below)? I'm new to Objective-C and I'm just not getting it right. From: http://lists.apple.com/archives/Webkitsdk-dev/2008/Apr/msg00027.html By default databases have a quota of 0; this quota must be increased before any database will be stored on disk. WebKit clients should implement the Web...

Create a colored bubble/circle programmatically in ObjectiveC and Cocoa

Can anyone guide me in the correct way to build a colored bubble/circle programmatically? I can't use images as I need it to be able to be any color depending on user interaction. My thought was maybe to make a white circle image and then overlay a color on top of it. However I am not sure if this would work, or how to really go about ...

How do I keep an NSPathControl updated with the path of the selected cell in an NSBrowser

I need to keep an NSPathControl updated with the currently selected path in an NSBrowser, but I'm having trouble figuring out a way of getting notifications when the path has changed from the NSBrowser. The ideal way to do this would just to be to observe the path key path in the NSBrowser, but that gives a KVO can only observe set<key> ...

Can you Bind to the timeInterval attribute of an NSDatePicker?

I've got a Core Data application that has an Event class, which has a start date and a finish date. It's trivial to bind these to a pair of NSDatePicker widgets, but I wanted to make it work with the NSRangeDateMode available in Leopard. The NSDatePicker has a pair of methods that deal with timeInterval, but I don't seem to be able to ...

Multiple windows or "pages" in an application

I am a newbie in Mac application development. I want to write a GUI application in Cocoa using Interface Builder. I want multiple screens i.e. when one button on a screen is clicked, another screen should be displayed. How can I activate a new screen at button click event? ...