cocoa

How to (programatically) change slides in a running Keynote presentation?

I'm working on a Cocoa application I'd like to use to remotely (on the same machine, from a different process) control which slide is currently displayed in a running Apple iWork '09 Keynote presentation. How should I approach this? ...

Why am I getting this error, when it cannot be true?

This is the error I get in the Xcode Debugger. But look here: How is this possible and how do i fix it? EDIT: ...

Archiving and Unarchiving results in Bad Access.

I'm having trouble setting up a model object to save the visual state of user generated CALayers in a simple graphics application for the iphone. I'm attempting to save the background color and frame of all the current layers on screen by passing those properties to model objects which implement the NSCoding protocol and then into an NS...

Objective-C @interface/pointer clarification.

Learning as always, was going along quite nicely, until I realized I had no idea what the differences meant between these. @class Player; @class Map; @interface View : NSView { Player* player_; Map* currentMap_; NSMutableArray *worldArray; NSMutableArray *itemArray; float cellHeight_; } @end Never mind, turns out...

How do I tell a (managed) object to notify its KVOs that one of its properties needs to be recached?

When we have an object who has a property that's generated based on other properties, usually we implement the +keyPathsForValuesAffecting{PropertyName} class method. What I'm trying to do is basically the same thing for a property on my NSManagedObject, but traversing a relationship. My model is simple; I have two Entities, App and Ve...

Help with Points between rounds in objective-c

I am new to objective-c and am having trouble figuring out a way to store points for multiple players in my game. I have 4 characters in my game that are all objects from the same class. 1 is controlled by the user and the other 3 are controlled by the computer. Each level in my game consists of 3 races. I need a way to keep track of eac...

How to efficiently assign NSStatusItem images and alternte images?

Let's say I have a code like this... - (id) init { ... self.myImage1 = [NSImage imageNamed:@"some_image_name"]; // setter retains ... } - (void) setStatusItemImage { [self.statusItem setImage:self.myImage1]; } I also want to animate the status item so I created 6 variants of the "updating" status item icon and loop it...

Implementing Model-View-Controller the right way

Working on a game in Objective-C/Cocoa for OS X, and I finished the prototype as much as it's worth being finished. It's a mess of code, being my first game, but everything works. I've been reading up on the best way to put things together, and MVC seems to make the most sense, but I'm a bit confused. Where does it start? With the cont...

Fetch MySql database from cocoa app - PHP bridging [Solved]

Hello to everybody, I'm trying to download a range of rows from my MySql database, through a cocoa app that I'm developing! To do all more easy, I use a php that receive an index from my app and send back all the rows up to that index. So, my cocoa code is: NSInteger index = 0; NSString *urlString = [NSString stringWithFormat:@"http://...

Callbacks in ObjC+Cocoa

Hi, I'm relatively new to Cocoa/ObjC. Could someone please help me change my code to use asynchronous network calls? Currently it looks like this (fictional example): // Networker.m -(AttackResult*)attack:(Charactor*)target { // prepare attack information to be sent to server ServerData *data = ...; id resultData = [self se...

Launchd Relaunch App on Quit

Hi Everyone: I am wondering how to set Launchd to relaunch my app if the user has not chosen to choose "Quit" from the top bar. There are cases where something may happen to the app, and it may force quit, and if a preference is selected I want it to relaunch automatically. I have looked into it before posting here, and I have heard t...

Some questions about Objective-C, Cocoa and Xcode.

When initializing an NSMutableArray array with object, Why put nil at the end? e.g. NSMutableArray *fruits = [[NSMutableArray alloc] initWithObjects:apple, watemelon, nil]; In Xcode, when using auto comple...

Passing a native pointer to performSelectorOnMainThread's withObject argument?

I want to pass a point to a C++ object to the selector invoked using performSelectorOnMainThread. Simply casting the pointer to an 'id' (objc_object*) doesn't seem to work. I could always write my own objective C wrapper class, but there should be a fairly standard way of doing this. I didn't really find anything on apple's documentation...

Problem with WebKit rendering google.com (and a few other sites)

I'm a noob to Cocoa programming, so please excuse the possible stupidity of this question. I'm trying to build a web browser using Cocoa/MacRuby but am running into this strange rendering problem - a lot of sites render just fine, but all Google sites and a bunch of other sites (such as the CouchDB website) render with very small fonts....

Resolving cast to pointer from integer of different size error in 64-bit conversion

I'm working on modifying the PTHotKeyLib to be 64-bit friendly, but I've run into an issue in the code that I'm not sure how to get around. In PTHotKeyCenter, the registerHotKey method create an EventHotKeyID instance and then stuffs the of PTHotKey object into the id attribute. The original code used a long. I converted it to NSInteg...

Cocoa: Dictionary with enum keys?

I need to create a dictionary/hashmap where the Keys are enums Values are some subclass of NSObject NSDictionary won't work here (enums don't conform to NSCopying). I could perhaps use a CFDictionaryRef here, but I'd like to know if is there any other way to achieve this. ...

Adding Padding To The 'left' of a Text Field.

I have a text field with a background but to make it look right the text field needs to have some padding on the left side of it a bit like the NSSearchField does. How would I give the text field some padding on the left? ...

Is there a reason not to use the same attribute names in Core Data entities?

I have a data model with several entities and some of those entities share attributes that naturally have the same name. Is there any reason to add detail to those names to help distinguish them or will I only ever use them in their fully qualified formats? For example, if my model had library, librarian, book, borrower and author entit...

Why would NSWindow with NSTableView not resize?

Here is my IB setup: http://img145.imageshack.us/img145/5929/picture1gxr.png When both NSScrollView and NSTableView are set to autoresize and autofill (all the arrows in the Autosizing section are checked) my window does not resize. Actually it resizes, but by a pixel, as if it remembers that it is not supposed to resize after I start ...

Clang Error on "Potential null dereference."

I keep getting Clang errors on the following type of code and I can't figure out why they're erroneous or how to resolve them to Clang's satisfaction: + (NSString *)checkForLength:(NSString *)theString error:(NSError **)error { BOOL hasLength = ([theString length] > 0); if (hasLength) { return theString; } else ...