objective-c

How does one publish a static void NSString in a protocol?

I have a defined a custom error domain that I want to publish in a protocol. The domain is defined in the implementation file like this: //in the .m file static void *MyErrorDomain = (void *)@"MyErrorDomain"; The .h file implements a protocol, and I would like to publish MyErrorDomain there as well. I can't, however, figure out the co...

Refresh the tableView when clicking on the tabBar

Hi folks, I want simply to refresh my tableView (on the iPhone) when I click on the related button in the tabBar... So, I think this has to be done this way : [self.tableView reloadData]; Right ? And done in the (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController...

iphone openGL error: expected '=', ',' ,';' ,'asm' ,or '_attribute_' before 'pyramidVertices'

Hey - just starting out trying to get some openGL into my iphone app and came across this error for this bit of code: static const GLfloat pyramidVertices[] = { 0.0f, 1.0f, 0.0f, -1.0f, -1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f }; am I not including something I should be? Withou...

UIScrollView - Input outwith visible area

I have a UIScrollView to which I add a bunch of UIImageView's as sub views. Everything works fine apart from that I get input from the subviews when they are outwith the visible area of the scroll view. I would have thought the scroll view would prevent any events from reaching subviews outwith the visible area by default but I presume t...

ViewDidLoad / Unload messages to super?

I have noticed code from other sources where the author has not added the messages to super that are shown below. I usually add them both, but I was just curious as to what they do and am I right in always adding them? -(void)viewDidLoad { //... other code [super viewDidLoad]; } -(void)viewDidUnload { //... other code [...

iPhone Obj C -- Sorting a Mutable Array of dictionaries -- display a string but sort by value

I have a NSMutableArray with 30 dictionaries inside of it. Each contains a name and a value. I currently have the names sorted so that the show in a table view alphabetically. However, I'd like to make a UIButton to give the option of STILL DISPLAYING THE NAMES, but ordered by the value. The value doesn't need to be displayed. Also, whe...

Why isn't my custom iPhone delegate working?

Hi all, I'm just trying to build a simple delegate, it compiles successfully but it doesn't seem to do anything right now. Please review my code below, both FirstViewContoller and SecondViewController have separate xib files, the SecondViewController has a button hooked up to the myMethod of course. I've been learning my way around obj...

Is there any difference between a CGRect and an NSRect?

Is there any difference between a CGRect and an NSRect? In particular, I'm wondering about the position of the origin. Are there any important differences I need to know about? ...

Core Data: How do I maintain without retain?

I am trying to debug a very nefarious problem with some iPhone Core Data code. The setup is this: I have a thread which exists to poll a web service and send its results via NSNotification to the main thread (passed in the userDict, a bunch of strings and NSNumbers). I'm using Tim Hatcher's notification library to pass to the main threa...

NSDictionary: URL-Encoding

Can anyone please review the following method and tell me if it is necessary to release the enumerator for the dictionary keys after using it? I'm new to objective c and not always sure, when to release variables returned from the SDK methods. I suppose the keyEnumerator method returns an autoreleased instance so I don't have to care abo...

'Could not instantiate class named UITableViewCellContentView' iPhone 3.1.2

I've created a nib for a custom UITableView cell and followed the documentation and different tutorials to get past this error and it just won't let up. I researched this error and people say it's when you #import a header but you didn't add the Framework. Well, UIKit is automatically added, and I removed and added it again for good meas...

Objective c doesnt like my unichars?

Xcode complaints about "multi-character character contant"'s when I try to do the following: static unichar accent characters[] = { 'ā', 'á', 'ă', 'à' }; How do you make an array of characters, when not all of them are ascii? The following works just fine static unichar accent[] = { 'a', 'b', 'c' }; Workaround The closest work ar...

What is the naming convention or coding standard for categories in objective-c?

I saw an example in The iPhone Developer's Cookbook that extends the UIDevice class using categories. @interface UIDevice (Reachability) // some methods @end Typically classes are nouns and methods are verbs. From my point of view categories are similar to subclasses, so I would name the category a noun such as NetworkedUIDevice. H...

Raw strings in objective-c?

Does objective-c have raw strings? Clarification: I mean raw strings similar to how Python has raw strings (follow the link and search for raw). ...

How to split a string into sentences cocoa

I have an NSString with a number of sentences, and I'd like to split it into an NSArray of sentences. Has anybody solved this problem before? I found enumerateSubstringsInRange:options:usingBlock: which is able to do it, but it looks like it isn't available on the iPhone (Snow Leopard only). I thought about splitting the string based on ...

How to get started coding In-App Purchase

Hi. I am working on in-app purchase. In my application we added the following code in appdelegate: #import "InappPurchaseAppDelegate.h" #import "MainController.h" #import "MKStoreManager.h" #import "MKStoreObserver.h" @implementation InappPurchaseAppDelegate @synthesize window; - (void)applicationDidFini...

Locking a screen in 10.6

Hi everyone, How would I go about locking a screen like Keychain does, meaning preventing all access to Dock, menubar, desktop, etc. Basically just a black screen that I can add a password field to, for the user to return to the desktop? I am well aware of the Carbon method, but I want the NSApplication method because this is an all ...

Cyclic Reference - protocols and subclasses

I'm getting some cyclic reference (I think) problems between a few classes that require imported headers due to either subclassing or protocol definitions. I can explain why things are set up this way but I'm not sure it's essential. Basically these classes are managing reciprocal to-many data relationships. The layout is this: Class A ...

need help in NSMutableArray!!!

Hi everyone I am just built a game with 8 levels. Each level has different information about target damage, total damage, and money. I will print these on the screen but first of all I need to store it somewhere and get the right level out. I think I should make an array. But I am not sure how to do it, i am not quite familiar with arra...

how to display array values in Objective-C

sir I'm getting updated values of X,Y,Z from acceleration function and I want to store these values in an array or list. Is there any way kindly suggest. - (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration { labelX.text = [NSString stringWithFormat:@"%@%f", @"X: ", acceleration.x]; ...