objective-c

Custom UITabBarItem Image/Title on iPhone

Hi all, I'd like to add a custom title to one of the predefined UITabBarItems. Whenever I select the particular instance I like in Interface Builder -- if I modify the the title it gets preset back to a 'custom' identifier. Ideally I'd like the book icon from the 'Bookmarks' identifier with my own custom title. Is this level of customi...

.Net guy needs some info on Cocoa

I want to do a little development in OSX and the iPhone. I've been a .Net/C# developer for years. I was wondering if there was anybody that had experience in both platforms that could tell me how they compare and contrast. I'd like to get an idea of what sort of learning curve I've got ahead of me. Thanks, Geoff ...

Sync Services Client and Schema Xcode Project Structure

I'm starting work on a project that will be primarily acting as a Sync Services client. Ideally, the project will have two components: a custom schema bundle and a preference pane. As a first step, I've created an Xcode project for the schema bundle. But now I find myself ready to start writing the code for the preference pane and the c...

Unit Test to verify object getting deallocated

What I am looking for is a way to programmatically verify a target object has been deallocated. Currently I have an NSLog statement in the dealloc methods of the objects I wish to observe. The unit testing framework is from the Google Toolbox for the mac, and it working nicely. I am just not certain how to frame this particular test. ...

How do SEL and @selector work in iphone sdk?

I have one sample code which get SEL from current object, SEL callback = @selector(mymethod:parameter2); And I have method like -(void)mymethod:(id)v1 parameter2;(NSString*)v2 { } Now I need to move mymethod to another object, say myDelegate. I have tried: SEL callback = @selector(myDelegate, mymethod:parameter2); but appears not ...

How do I generically use KVC to update fields?

Say I have the following Objective-C class: @interface Foo { int someNumber; NSString *someString; } and for reasons I won't get into here, I want to use KVC to update, in a generic fashion, the values for those variables: [f setValue:object forKey:@"someNumber"]; or [f setValue:object forKey:@"someString"];` If object ...

Is there an Objective-C Wrapper for gSOAP?

I'm going to use gSOAP to interact with a WCF webservice in my Mac project. It does pretty much exactly what I need and it does it well (pretty much the exact opposite of WSMakeStubs;)). The only downside is that it's C/C++ only, meaning I either need to convert all my types into C types on the fly or write a complete wrappering solution...

Is it true that one should not use NSLog() on production code?

I was told this a few times in this very site, but I wanted to make sure this is really the case. I was expecting to be able to sprinkle NSLog function calls throughout my code, and that Xcode/gcc would automatically strip those calls out when building my Release/Distribution builds. Should I avoid using this? If so, what alternatives ...

Accessing Controller data member in Model class

I am using Xcode to develop a GUI application. I have a model class and a controller class. I have a NSTextView data member in my controller class. How do I access this variable from the model class? ...

Sound not working in iPhone Simulator?

Somehow my iPhone Simulator is unable to play sounds. First an app I'm working on using AudioServicesPlaySystemSound() stopped working.. I spent a while debugging this but sound is still working on the iPhone when I run the app on the device. I get the same results with other iPhone apps such as the sample Crash Landing app. I can't f...

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...

Objective-C and sqlite's DATETIME type.

I have a sqlite3 table that I'm trying to map to an object in objective-C. One attribute of the table is 'completed_at' which is stored as a DATETIME. I want to create a property on my objective-C class (which inherits from NSObject) that will map well to the 'completed_at' attribute. Objective-C has an NSDate type but I'm not sure if ...

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 ...

Unable to call an Objective C method from a C function

Hi, I am using MVC architecture for a GUI application. The model class has some C functions. One of the C functions calls some methods of Objective-C class. I call those methods using an object of that class. The strange thing happening is that methods previously to the an xyz method are called perfectly but when that xyz method is calle...

How would you construct and interact with a grid like a Sudoku board?

What do you think is the best way to implement an interactive grid similar to a Sudoku board for a native iPhone application? I did not see an object to fill this need in the SDK. Should I make a custom control for an individual cell, then initialize as many of them as I need in a grid form? Any and all comments are welcome. Thanks!...

How do I cast id to a float?

I'm having trouble with this code: NSRect itemFrame; id item; // code to assign item goes here. itemFrame.origin.y -= [item respondsToSelector:@selector(selectedHeight)] ? [item selectedHeight] : [self defaultSelectedHeight]; This is the problematic bit: [item selectedHeight] The compiler is assuming that the return type is id. I...

Best way to save data on the iPhone

I am writing an iPhone application, and need to save the state of my application (5K or so). My main worry is data persisting across upgrades. Some of the applications I use clearly got this wrong, and I would prefer not to! ...

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...

What's your Objective-C coding style?

The first thing I do when I incorporate any third party code into my application is reformat it to my personal coding preference: // Single line comments only // I never put spaces inside my parenthesis -(void)myOCDMethod { // If an if or for statement has only one instruction, I don't use brackets if(this) [self t...

IPhone sync/app backup - can an app do something at that time?

Hi I was wondering if there is a hook in the iphone sdk that allows an app to know when its being sync'd / backed up - so that it could do something, eg connect to a website to also backup data. I am assuming not... but I could be wrong. Thanks, Chris ...