objective-c

Why does Cocoa return an empty string occasionally?

I have some code in my application that looks something like this: char *hash = (char*) sqlite3_column_text(get_bookmark, 0); NSString* postHash = [NSString stringWithUTF8String:hash]; This works for me every time; I've never seen it not work. Most of my users do not experience problems (as far as I know). However I find that postHash...

BOOL changing value in objective-C?

I am having trouble with a BOOL property and I can't quite figure it out. I have the following set in my .h file: BOOL myVar; @property BOOL myVar; Then in my .m file I synthesize myVar and have a method that set myVar=YES; and also starts a timer. The timer then calls another method that tries to read the value of myVar. To test f...

How do you calculate the bouding rect for a string in Objective-C/Cocoa?

Using Objective-C/Cocoa how do you calculate the width and height required to draw a string based on a particular font? In C#/.Net you can do it like this: SizeF textSize = graphics.MeasureString(someString, someFont); Is there something like that available in Objective-C/Cocoa? ...

How to make an iTunes like (playlists, library) left-sided (collapsible) navigation bar?

I am talking about the navigation area on the left side of iTunes for Library and Playlists. I'm wondering if this is a built in class (which I couldn't find documented) or something custom implemented by Apple. I'm working an a mac application where I want to include that type of navigation. I want to allow people to "fold" the catego...

What is the tail truncation mark on iPhone?

I want to add some tail marks to several strings. Are there any marks like '\n' on iPhone? ...

How can I create a Installer package for iPhone ?

How can I create a Installer package for iPhone ? ...

What are some options for XML on the iPhone?

I have implemented NSXMLParser in my app and I am reviewing alternatives. My complaints about NSXMLParser are that it's convoluted to implement for simple files, and it's not the zippiest thing around either. So far I've identified: TouchXML Objective-XML Any others? And what's your experience with these? Thanks for your input! ...

Dot Operator in Objective-C 2.0

Just picking up Objective-C 2.0 and wanted to know if there is any advantage in using the dot operator for accessing properties instead of the "old" way. Short example of what I mean. "old" way: [myFraction setNumerator: 1]; [myFraction setDenominator: 3]; "new" way: myFraction.numerator = 1; myFraction.denominator = 3; Thanks...

Arrow keys with NSTableView

Is it possible to navigate an NSTableView's editable cell around the NSTableView using arrow keys and enter/tab? For example, I want to make it feel more like a spreadsheet. The users of this application are expected to edit quite a lot of cells (but not all of them), and I think it would be easier to do so if they didn't have to double...

Why does this create a memory leak (iPhone)?

The first line of code creates a memory leak, even if you do [self.editMyObject release] in the class's dealloc method. self.editMyObject is of type MyObject. The second line incurs no memory leak. Is the first line just incorrect or is there a way to free the memory? //creates memory leak self.editMyObject = [[MyObject alloc] init...

Why is autorelease especially dangerous/expensive for iPhone applications?

I'm looking for a primary source (or a really good explanation) to back up the claim that the use of autorelease is dangerous or overly expensive when writing software for the iPhone. Several developers make this claim, and I have even heard that Apple does not recommend it, but I have not been able to turn up any concrete sources to ba...

Memory issue of NSString

Hi, I have got a problem with NSString. NSString* str = [[NSString alloc] initWithString:@"Hello world"]; In the code above, do I need to release the object str? According to the rule, this object is created with alloc, so it should be explicitly released with the release method. However, I can't find any memory leaks in Instruments ...

How can I implement "Drag" option in cocos2d ?

hello, I trying to develop a game for iPhone by using cocos2d. I need DRAG option in cocos2d. Is it possible to implement drag option in cocos2d ? ...

How to hide 'Back' button on navigation bar on iPhone?

I added a navigation control to swith between Views in my app. But some of the views shouldn't have 'Back'(the previous title) button. Any ideas about how to hide the back button? ...

WiFi iPhone Application

Hi im working on an iPhone application which requires communication between 2 devices through WiFi. Can somebody please help me by providing a simple iphone application code for the same which is able to communicate data between the devices...i hv gone through the "witap application" available on the developers site but wasnt able to un...

UICachedDeviceWhiteColor and NSAutoRelease for table cell mem leaks

I have a memory leak that displays UICachedDeviceWhiteColor. I'm not using UICachedDeviceWhiteColor anywhere and a search on it turns up people saying this is a bug in the iPhone-SDK. I found this blog entry: http://piezoelectrics.blogspot.com/2009/02/uicacheddevicewhitecolor-leak-in-iphone.html but I can't find #import "NSAutorelea...

Is there a difference between YES/No,TRUE/FALSE and true/false in objective-c?

Simple question really; is there a difference between these values (and is there a difference between BOOL and bool)? A co-worker mentioned that they evaluate to different things in objective-c, but when i looked at the typedefs in their respective .h files, YES/TRUE/true were all defined to 1 and NO/FALSE/false were all defined to 0. ...

iPhone Views at Runtime?

Hello, I am new to the iPhone SDK and am trying to create 3 views and switch between them. Data will come from a server and I will basically be showing 1 view and caching the other two. So far I am just trying to create a view and display it at run-time. My code is listed below. It shows only a blank screen and I think I am missing a key...

iPhone: Extending the Utility Template

Extending the Utility Template I'm working with the Xcode Utility template (Mainside/Flipside) and I need to add a new screen. I've added: docView.xib (copy of FlipsideView.xib) docView.m docView.h docViewController.m docViewController.h In rootViewController.h I added: UINavigationBar *docNavigationBar; docViewController *do...

What leads to a no suitable image found error on Mac OS X?

I followed Chris Hanson's advice about debugging framework unit tests in Xcode 3.1, but when trying to run the custom executable, the program crashes, stating the below error message [substituted $(BUILD_PRODUCTS_DIR) for the real location of the build products]. 2009-03-02 19:56:03.414 otest[28059:10b] Error loading $(BUILD_PRODU...