objective-c

How do I set an uninitialized value in Objective C?

This question might be off base, but here's the problem I'm having: I'm trying to run an example from the iPhone SDK, and I'm running into an access violation. I've traced down some behaviour that I think is suspicious. Here's what the class looks like: @interface TableViewCell : UITableViewCell { @private UILabel *_earthqua...

Using a NSTreeController, NSOutlineView with Drag and Drop

I have found a Tutorial here on how to implement drag and drop in an Outline View. The only problem I have is I don't know where to put the code from the tutorial. I would appreciate it greatly if you could tell me where I should put the code in a Xcode Project to make it work. Thanks! ...

longer than five seconds iphone sounds

Hey everyone. The following is the code that I am using to play random sounds on the iPhone simulator. Some of the 30 or so sounds won't play and after some investigating I found out that the ones that weren't playing were longer than five seconds. Does anyone know why this is? Thanks in advance for your help! NSString *path = [[NSBund...

get section number and row number on custom cells button click?

i have tableview with custom cell.the table is divided in many section and rows.i have a custom button on cell. now i want to get section number and row number when i click on that button.? any idea regarding this ...

NSUserDefaults vs sqlite3

I have a small iPhone app that stores a list of objects. The user can add and remove objects, but this list will remain fairly small (most users would have 10-30 objects). NSUserDefaults seems much easier to work with, but will sqlite3 be faster? With only 30 "records" will there be any noticeable difference? ...

How to properly display iPhone Address Book in Landscape mode?

I've added an ABPeoplePickerNavigationController but it doesn't display correctly in landscape. I'm using the iPhone SDK 2.2. ABPeoplePickerNavigationController *ab = [[ABPeoplePickerNavigationController alloc] init]; [ab setPeoplePickerDelegate:self]; [self presentModalViewController:ab animated:YES]; It displays like this with ...

"isEqualToString" Cocoa error

Hello. I am getting an error in my console: 2009-05-30 20:17:05.801 ChuckFacts[1029:20b] *** -[Joke isEqualToString:]: unrecognized selector sent to instance 0x52e2f0 Here is my code that I believe the error is coming from: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexP...

Library for Image Recognition in Obj-C?

Hi there, I'm looking for some library that will allow me to identify black dots on a white background. Preferably in C or objective-c. Also, what keywords can I use in my search for such algorithms? I've found a lot of stuff about image recognition but nothing that ressembles what I'm looking for. thanks! ...

UITextView is being cutting off top half of top line of text.

So I have a UITextView that is cutting off the text in the top line. and each subsequent return takes the next line to the same position where it is cut off. I cant see how this is happening following is all the configuration that i have set for the object. ResolveNotes = [[UITextView alloc] init]; ResolveNotes.backgroundColor = [UI...

How do I get the external ip address with NSHost?

I'm trying to find my external IP address, but I get local ones only, behind the NAT. NSArray *addresses = [[NSHost currentHost] addresses]; Is there a way to print out the public address? Using NSHost is it a good idea? ...

How do I call +class methods in Objective C without referencing the class?

I have a series of "policy" objects which I thought would be convenient to implement as class methods on a set of policy classes. I have specified a protocol for this, and created classes to conform to (just one shown below) @protocol Counter +(NSInteger) countFor: (Model *)model; @end @interface CurrentListCounter : NSObject <Count...

Problem with word "Nestlé" in an XML doc (UTF-8 encoding) using NXXMLParser. Any idea?

Hi all, We are using NSXMLParser in Objective-C to parse our XML document, which are all UTF-8 encoded. One document has a string "Nestlé" in it (as in ...<title>Nestlé Novelties</title>...). The parser just quit, reporting an error with error code=9, due to the French letter "e" at the end of the word "Nestle". Furthermore, we tried us...

How to I pass @selector as a parameter?

For the method [NSThread detachNewThreadSelector:@selector(method:) toTarget:self withObject:(id)SELECTOR]; How do I pass in a @selector? I tried casting it to (id) to make it compile but it crashes in runtime. More specifically, I have a method like this +(void)method1:(SEL)selector{ [NSThread detachNewThreadSelector:@selector(m...

What is the proper way to manage memory of a class variable / method in objective c?

I'm learning Objective - C and coming from a garbage collected world. I am creating a class (static) variable of a dictionary and I am unsure if I am doing it properly for memory management or not. I'm using a convenience method so the object should be auto-released, but I don't really know if I need to release or retain it in my class. ...

In Objective-C, do I redirect a containing instance's method without subclassing it?

In Objective-C, how do you rewire a class's instance method to call a method in another class? Say a UIView class A contains another UIView class called childA. I want it so that when childA's drawRect is called, a method in class A is invoked without having to subclass childA and do the desired call in its drawRect there. How can thi...

Getting Image from URL Objective C

I'm trying to get an image from an URL and it doesn't seem to be working for me. Can someone point me in the right direction? Here is my code: NSURL *url = [NSURL URLWithString:@"http://myurl/mypic.jpg"]; NSString *newIMAGE = [[NSString alloc] initWithContentsOfURL:url encoding:NSUTF8StringEncodi...

How do I draw text into a containing view in UIView?

In UIView, I want to draw text into its containing view using drawInRect:withFont:lineBreakMode call but that operates on the current context only. Is it possible to draw that text into a subview from current view? The subview is a generic UIView instance and I don't really want to create a new UIView-derived class just for this purpos...

How do I end on a different frame than the start frame with a UIImageView animation?

I am creating an animation using UIImageView. I assign the start image with initWithImage because the animation isn't supposed to start immediately so this is the static image that is displayed first. However, once the animation is done playing, this image (the one I assigned with initWithImage) is also the one that that displays again....

What is the equivalent (if any) to the C++/Windows SendMessage() on the Mac?

Is there an equivalent function to SendMessage in the Mac OS? ...

NSObject release... Still shows up in ObjectAlloc

I have been tracking down why NSObject references, while being explicitly release, still show up in ObjectAlloc. In fact, have reduced down NSObject to a basic shell, with a [[myObject alloc]init] immediately followed by a [myObject release], and it does not look like it is being released in ObjectAlloc. This is a big problem with a Na...