objective-c

BDD Testing frameworks - RSpec and Cucumber

I was looking into RSpec and cucumber and was wondering what this adds to unittesting? On the one hand you may say that having "stories" or more readable tests is a plus, but doesn't all this aliasing of functions names go against using unittests as examples of code usage? ...

How to make NSColorPanel (using NSColorWell) and NSFontPanel's color panel co-exist?

I have a preferences panel in my application in which I have a NSColorWell for setting some background color and a button which opens an NSFontPanel for choosing a font. The behavior I want to have is the following: When I click on the NSColorWell then drag over some color in the panel, I want it to change the background color in my "...

iPhone SDK - UIActionSheet - Dynamic Button Titles

I have a requirement in an application where I need to be able to add otherButtonTitles dynamically, dependent upon some BOOL switches that a user has specified in the settings. However, I can't seem to figure out how to go about doing this in the UIActionSheet initialization. I've tried to pass a NSString array (NSString[2]), and also...

Parameters from observeValueForKeyPath:ofObject:change:context:

I was wondering what the parameters from this method would return. - (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context; In the documentation it says keyPath The key path, relative to ob...

Programmatically set UITableView datasource and delegate

I have a UIScrollView that contains multiple UITableViews horizontally - all of which are created programmatically depending on the user's action. Say I have 4 UITableViews, how do I set the datasource and delegate for each one programmatically? I understand there are tableViewX.dataSource and tableViewY.delegate methods; and I assume I...

GNUstep And GTK

Hello, I'm learning Objective-C using GNUstep, because I don't have a Mac and the GNUstep GUI applications have that Window Maker style, but it's possible to develop this GUI applications using GTK? Thanks. ...

Retrieving the information in the `change` dictionary from KVO.

The method - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { } has a parameter change which is a dictionary that contains information about the nature of the value change, how would I find out what was in this dictionary? ...

One viewcontroller for multiple UITabBar sections

I'm currently developing a simple iPhone application using a UITabBar and table views for displaying data. The tabbar contains 8 sections, each containing the same view but using a different data source, the title of the table view is also different, but apart from that the views are the same. I'd like to use the same viewcontroller for...

How do you find how much disk space is left in Cocoa?

I suppose I'd like to be able to find out for any storage, not just the system disk, but that's most important. ...

Stopping a loop.

As explained in my earlier question … This code … - (void)syncKVO:(id)sender { NSManagedObjectContext *moc = [self managedObjectContext]; [syncButton setTitle:@"Syncing..."]; NSString *dateText = (@"Last Sync : %d", [NSDate date]); [syncDate setStringValue:dateText]; NSEntityDescription *entityDescription = [NSEntit...

how to write an If statement, to compare core data attribute value?

i'm an objective-c newcomer. im trying to compare a core data entity attribute value and having trouble with the syntax. i just want to know the best way way to write the if statement to compare values. in this example, the someAttribute attribute is a boolean, and its default is NO. NSString *myValue = [NSString stringWithFormat:@"%...

How do I use the SQLite3 import command using the C API?

I have the following code: int rc; rc = sqlite3_exec(sqlite3_database, ".import mydata.csv mytable", callback, 0, &errMsg); After this gets run, errMsg contains this error message: near ".": syntax error I assume that it does not recognize the import command. However, this command works when running it from the sqlite3 program on t...

is it good form to release self in an init method when that method allocates and returns something else?

In my code, I have something that looks like this: @implementation MyClass - (id) initWithType:(NSInteger)type { [self release]; if (type == 0) { self = [[MyClassSubclass1 alloc] init]; } else { self = [[MyClassSubclass2 alloc] init]; } return self; } //... @end which I think handles any potential memory leaks. Ho...

Parse Query String into a Structured NSDictionary

I have a query string: a=1&b=2&c[1]=3&c[2]=4 etc… I want a NSDictionary where a => 1, b => 2, c => [3,4]. Notice that that the value for c is an array. It should also be able to handle something like c[1][2]=5 to make an array of arrays c => [[5]]. Of course I can do it myself by splitting on the & and =, but what about other cases s...

Xcode: Build architecture specific per file compiler build settings

Hello, in my iPhone project I am using some inline asm, which is excluded if the target architecture is the device and not the simulator. Since some of the inline asm code is arm only and not thumb I need to specify the c flag -marm when compiling it for the iPhone, since it otherwise trys to compile the code with the thumb instruction...

Xcode and Generate Debug Symbols

Which setting in Project Settings page needs to be set in order for Xcode to generate debug symbols for a project? If I set 'Generate Profiling Code" to checked, as soon as I try to build, I get the error, cc1obj: error: unrecognised debug output level "-full" If not, the other way to do this I thought was by setting the 'OTHER...

Getting the Minimum Value of an Attribute in a NSSet Made from a One-to-Many Relationship in Core Data

I have several objects set up in Core Data, one of which is "Deck" and one of which is "Card". "Cards" have several numbered relationships, including "id". "Deck" has a one-to-many relationship with cards. What's the best way to find the Card in a Deck that has the minimum value to some numbered attribute, such as id? Clearly I can get...

Using enum types as properties in Objective C

I'm a veteran .NET developer making my first foray into Objective C programming. I'm having difficulty with a property of an enum type. Some context... I have an class header and enum like this: typedef enum { Open, Unavailable, Unknown } LocationStatus; @interface Location : NSObject { LocationStatus status; } @pr...

Odd behaviour of an NSArrayController

I have a Core Data project with an NSTableView bound to an NSArrayController. I have two buttons, one adding an object to the table and one removing the object from the table. The Add method uses a custom method which directly creates a new Core Data object. The remove method uses the standard Remove method of an NSArrayController. My ...

Pointer to Pointer to UIImage created by NSURLConnection

Hey all, here's the deal... I've got a UIImage that is being loaded in the background via an NSURLConnection within a subclassed UIImageView. Until the data finishes downloading, a placeholder image is shown. The UIImage needs to be used by another, separate UIImageView, as well. The problem I'm having is that if I set the second UIIm...