cocoa

Another appropriate use of @property design question

This is a followup to Avoiding @property-itis. UIWebView has the following property declarations: @property(nonatomic,readonly,getter=canGoBack) BOOL canGoBack; @property(nonatomic,readonly,getter=canGoForward) BOOL canGoForward; UIScrollView has these: @property(nonatomic) BOOL canCancelContentTouches; Yet, UIResponder has - (B...

Hooking Up an NSTableView to an XML-RPC Server

There are multiple ways to fill an NSTableView up with data through either bindings, delegates, or data sources. What is the best way to go about filling up the tableview with data that is changed pretty frequently from an XML-RPC server? I'm targeting Mac OS X 10.5 only and there are lots of examples on how to do it, but nothing very ...

How can I detect that the number of rows in an NSTableView has changed?

I have a custom NSTableView subclass which is bound to a data source (an NSArray) which updates asynchronously. When items are added to the array, rows are automatically added to the tableview. Awesome! My question is this: How can I detect that this magic has happened so that I can perform some other tasks related to the display of my ...

Determining if a Unicode character is visible?

I am writing a text editor which has an option to display a bullet in place of any invisible Unicode character. Unfortunately there appears to be no easy way to determine whether a Unicode character is invisible. I need to find a text file containing every Unicode character in order that I can look through for invisible characters. Wo...

How can I make my NSScroller subclass have a different width?

I am trying to create a custom subclass of NSScroller. I have created the class, and set it as the vertical scroller on an NSScrollView in IB. When I run my project, the drawRect: method is called for my subclass, so I know that it is properly connected. Now, How do I change the width of my fancy new NSScroller? No matter what I do to i...

How do you develop an application to draw, edit and save UML models in Cocoa?

Will the individual UML diagram shapes be NSView subclasses or NSBezierPaths? How are the diagrams created and managed? ...

Algorithm: Keeping count of key/value pair in NSDictionary

Being new to Cocoa, and probably not knowing all of the potential classes available that already have this functionality neatly wrapped in an OO class, here's an algorithm inquiry. What's the best bet to count how many times a particular key occurs in an array of multiple NSDictionary instances? Essentially my data structure (in this ca...

Dependency injection framework for Cocoa?

Interface Builder can be used for basic dependency injection in a Cocoa app, but is anyone aware of more complete dependency injection frameworks for Objective-C/Cocoa for when you don't want to instantiate objects in a NIB file? Edit To clarify, I recognize that IB can be used for basic DI, but I'm looking for a framework with more co...

Good database library/ORM for cocoa development

I am developing a cocoa application that will be making heavy use of both web services and a standard dbms (most likely MySQL) and I am wondering if anyone has a good option for a database library or ORM solution they have used. CoreData is not an option due to the need to support a standard DBMS and to be able to modify the data outsid...

NSBorderlessWindowMask Window wont show NSPanels if not front most window

I have a window that is set with NSBorderlessWindowMask, and also kCGDesktopWindowLevel. When a NSPanel is supposed to appear from say the selection of a Dock Icon menu or a Status Bar Item menu, the NSPanel will not display if the application is not the front most window. So this program at this time only has a Status Menu Item (think ...

Algorithm: array of arrays in Cocoa Touch (perhaps using NSCountedSet)

This one is a bit tedious in as far as explaining, so here goes. I'm essentially populating a tableView on the iPhone with multiple sections, and potentially multiple rows per section. To my understanding, it's best to have an array of arrays so that you can simply determine how many sections one has by sending a message to the top level...

Debugging an exception in a Cocoa app

I am working on an app with an NSTextView. When I paste random bytes into it (say, from a compiled C program) it displays gibberish, as it should. However, when I -setShowsControlCharacters:YES, the same causes a crash and gives the following error multiple times: 2008-11-22 00:27:22.671 MyAppName[6119:10b] *** -[NSBigMutableString _g...

Getting a unique ID for a window of another application

Hello all. I'm a newbie Cocoa developer and I'm developing my first application. I want to read a unique identifier from any window of any application - whether it's Cocoa or Carbon. Cocoa applications make their window IDs available to AppleScript (although I'm sure there's a much better way to do this through a proper Objective C route...

NSInvocation for Dummies?

How exactly does NSInvocation work? Is there a good introduction? I’m specifically having issues understanding how the following code (from Cocoa Programming for Mac OS X, 3rd Edition) works, but then also be able to apply the concepts independently of the tutorial sample. The code: - (void)insertObject:(Person *)p inEmployeesAtIndex:(...

How do I create a Cocoa window programmatically?

My Cocoa app needs some small dynamically generated windows. How can I programmatically create Cocoa windows at runtime? This is my non-working attempt so far. I see no result whatsoever. NSRect frame = NSMakeRect(0, 0, 200, 200); NSUInteger styleMask = NSBorderlessWindowMask; NSRect rect = [NSWindow contentRectForFrameRect:frame st...

NSTableView - NSButtonCell Data Source type?

I've got a table with checkbox-style cells, and I can't figure out how to get these buttons to take on the titles that they're supposed to. Should the data source be an array of strings? An array of dictionaries (string/boolean)? An array of NSButtonCells? None of these seem to work =/ ...

What are the factors to decide between using Core Data versus rolling out a custom model?

There might be applications that are not suited for Core Data - image manipulation programs like Photoshop or Gimp for example. But for applications that are suited for Core Data, say Address Book or iCal, what is the criteria to choose Core Data over a custom model? ...

How can I pass a class name as an argument to an object factory in cocoa?

I am working on an object factory to keep track of a small collection of objects. The objects can be of different types, but they will all respond to createInstance and reset. The objects can not be derived from a common base class because some of them will have to derive from built-in cocoa classes like NSView and NSWindowController. I...

Handling Callbacks in Objective-C

Hi, I have a method in an objective-C class. It has 2 callback functions written in C. The class pointer i.e. self is passed to these functions as void *. In the C functions I create a pointer of type class and assign the void * parameter. The first callback function executes successfully. But the void * pointer becomes nil in the 2nd ca...

Obtaining an NSDecimalNumber from a locale specific string?

I have some string s that is locale specific (eg, 0.01 or 0,01). I want to convert this string to a NSDecimalNumber. From the examples I've seen thus far on the interwebs, this is accomplished by using an NSNumberFormatter a la: NSString *s = @"0.07"; NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init]; [formatter setForm...