cocoa

NSFetchedResultsController

I have a table view managed by a NSFetchedResultsController. I am using the Apple-provided boilerplate code in my TableViewController. My predicate retrieves objects based on their name. Everything seems to work fine when it comes to adding/deleting objects using the 'edit' button. If I programmatically change an object's name, things al...

How to convert a string into a series of keystrokes?

I'm using CGPostKeyboardEvent((CGCharCode)0, (CGKeyCode)55, true); to simulate key presses, but say I had a string that I wanted to convert to key presses. How would I go about dividing an NSString up into single characters, and then converting those into key presses? Thanks! Edit: OK I think I found a solution, but I am unable to get...

Proposed solution to NSTreeController displaying duplicate enitities

As many of you may know, an NSTreeController bound to an outline view can display duplicates while presenting core data entities. A temporary solution is to add 'parent == nil' to the predicates, but this only returns parent entities. If, for instance, a user is searching for a sub-entity, the requested sub-entity won't be displayed. ...

Cocoa Callback Design : Best Practice

I am writing the middleware for a cocoa application, and am debating over how exactly to design callbacks for many long running processes. When the UI will call a function which executes for a long time, it needs to provide a delegate to allow at least: Report of Success (with return value) Report of Failure (with error value) Report ...

Core Animation image change in IKImageView?

Is there any way to animate (using one of the supplied Core Animations) an image change in IKImageView without resorting to using two independent IKImageViews upon a new image load? ...

How to use asyncsocket setRunLoopModes with separate thread?

I am new to cocoa and in my cocoa application, I'm trying to create the websocket in a new thread but it is not working. I'm doing the following when initializing mySocket class, NSThread *thread = [[NSThread alloc] initWithTarget:self selector:@selector(runEventLoop) object:nil]; [thread start]; .... - (void) runEve...

How to create a Cocoa library and use it in python.

Hello. I've been making a game and the python library I was used is terrible (Pyglet). I want to try using Cocoa for the OSX version. I'll be able to figure out using the objects from classes like NSWindow and NSOpenGLView and then put these objects in my own class for the game loop. I have no idea how I can use PyObjC to load a dynami...

Detecting whether a process starts and finishes with notifications in cocoa

Hi everyone, I was wondering if there was a way that I could get notifications of when a system process from /usr/sbin starts and finishes. Is it possible to attach NSTask to the running process without launching a new one? Preferably without polling please :! ...

Store enums in an NSArray?

Hi, I'm new to Objective-C, but experienced in C++ and C. I want to store some enum constants in an array. In C++ I would do something like this: enum color {RED, BLUE, YELLOW, GREEN}; vector<color> supportedColors; supportedColors.push_back(RED); supportedColors.push_back(GREEN); But the NSArray will only store object pointers (id...

Help me trace this log message: "invalid `Widths' entry in font dictionary"

I have a pretty simple application using standard Cocoa controls, and I'm seeing this message several times in my Debugger Console in Xcode: invalid `Widths' entry in font dictionary. That is the whole line. There is no other information about where this came from or what it might mean or how to get rid of it. Google was no help in a ...

Fetched properties as properties of an NSManagedObject subclass

I have a subclass of NSManagedObject (NSMO) called Team. Team has a one to many relationship with another NSMO subclass called Contract. Contract has a 1-to-1 with Player (another NSMO). I would like to simplify my code that uses Team and be able to just refer to its "players". Players will just be an array of players that have a contrac...

Extra error on unit test in Xcode

I always have a extra error when I try check if my expected error appear in my unit test. First appear this error: "command /bin/sh failed with exit code 1" then my expected error. Is this normal, I'll always see the first error? ...

Possible embedded database engines to use in an application

Are there any alternative to SQLite to use as embedded database engine? ...

What's wrong with my Objective-C?

Something's wrong with my code here and I can't quite figure it out. Edit: Please correct this code. Thanks! int stringLength = [theData length]; for (int i = 1; i <= stringLength; i++) { unichar currentCharacter = [theData characterAtIndex:i]; int currentCharacterCode = keyCodeForKeyString(currentCharacter); ...

how to print current memory size in my app?

hi,all。 i want know current memory size in my app,for example,i wanna print the heap or stack memory size use in one class or method,how to do it? has some method to get the memory size? ...

How to disable word-wrap of NSTextView?

NSTextView does word-wrap by default. How can I disable this? I'm making a JSON code viewer, so I have to disable this. ...

Cancelling NSOperationQueue from within NSOperation

I have some iPhone SDK 4.0 code which initializes an NSOperationQueue and then adds three classes (ClassA, ClassB, and ClassC) to run one after the other. ClassA, ClassB, and ClassC are all sub-classes of NSOperation. The relevant code is included below. ClassA *classA = [[ClassA alloc] init]; ClassB *classB = [[ClassB alloc] init]; Cl...

How do I save objects in NSMutableArray after application is terminated?

Hi, I would like to save objects that the user adds to a NSMutableArray that I will be able to see and use even if I quit the application. I tried to use NSUserDefaults but I'm doing something wrong. Thanks! ...

Objective C implementation of controlTextDidChange: in .h and .m files

Can someone post the simplest example on how to use controlTextDidChange with a text label in the .h and .m files? Another part of my code constantly changes the value of this text label multiple times a second. I just need another part of my script that can tell if the value has changed and preform an action. All these websites out ther...

What's the most straightforward way of painting RGBA data into a view on Mac OS X?

Hey guys, Long story short, every 60th of a second I have a relatively small buffer (256x240) of RGBA data (8 bits per component, 4 bytes per pixel) that is refreshed with new data, and I want to display it (I guess inside an NSView, but anything is welcome). What's the most straightforward way to do it? Building a CGImageRef from a CGB...