objective-c

arrayWithContentsOfFile: results in crash.

I am creating an application and I get an EXC_BAD_ACCESS error. CODE @interface DNProjectsCategory : DNCategory { NSArray *projects; } @property(nonatomic, retain) NSArray *projects; @end And: @implementation DNProjectsCategory @synthesize projects; // MEM - (void)dealloc { [projects release]; [super dealloc]; } // INI...

iPhone - NSNumberFormatter problem

I am using NSNumberFormatter to create a currency formatted string. Everything works fine on most devices, but on some devices for example devices with Korean language, the $ sign shows up as a rectangle. NSNumberFormatter *currencyStyle = [[NSNumberFormatter alloc] init]; [currencyStyle setFormatterBehavior:NSNumberFormatterBehavior10_...

Limit scope of NSMetadataQuery

Hi, I was trying to restrict the scope of a NSMetadataQuery item. I know there's the -setSearchScope method, but it lets me only decide in which directories the item will search. What if I need to exclude one or more directories from the scope? ...

How can I use iOS's standard red number badges within my app?

Hi guys, I know that it's trivial to add a red number badge to an app's icon on the home screen. What's the best way to get a badge that looks like this within my app? There are some classes I've found online that can do this, such as MKNumberBadgeView, but none that I've found look completely right. Facebook, for example, implements re...

ObjC - UIViews: animating view and subview independently?

Hi! I have an UIView and its subview. When I animate myView (size.x+20) my subview is being animated too, however I want to translate my subview at the same time independently(origin.x-40) (without the subview moving because of the resizing of myView). I was able to do it by adjusting the translations (or better position, because I mig...

How to implement a custom protocol

In this part of my code I get a warning message saying it doesn't implement the custom protocol I made. detailViewController.delegate = self; How do I implement the protocol? Then when I run the program it crashes saying '-[DetailViewController setDelegate:]: unrecognized selector sent to instance 0x6a1c450' ...

How to Format Unknown Date Format in Objective-C

I've probably overlooked something simple, but I can't figure out how to convert a specific date format in Objective-C. I'm receiving dates in this format: Sun, 10 Oct 2010 01:44:00 +0000 And I need to convert it to a long format with no time, like this: October 10, 2010 I've tried using NSDateFormatter, but when I try to get a date ...

NSString with Instance Variable

So, I want to put an instance variable into a NSString like this: NSString *theAnswer = (@"The answer is %@\n", self.answer); I'm not sure am I right or not. I thought that NSString would work like NSLog but apparently it doesn't. theAnswer returns as only the instance variable without "The answer is" Can someone tell me why and h...

Easily extendable Objective C XML parser?

If I knew how to phrase this I could probably find the answer on Google. I need an XML parser which I can call out to other XML parsers with. For example: <car> <driver> <name /> <age /> <height /> </driver> <make> <name /> <nationality /> <age /> </make> <engine> ...

stringWithFormat vs. initWithFormat on NSString.

I am wondering what differences such as disadvantages and/or advantages there are to declaring an NSString this way: NSString *noInit = [NSString stringWithFormat:@"lolcatz %d", i]; as opposed to: NSString *withInit = [[NSString alloc] initWithFormat:@"Hai %d", i]; What was the motivation of putting stringWithFormat instead of just...

how to create session (iPhone)?

How do you log the user in, create and store the user's session? (It will timeout on its own aswell? do you need to store it in a database?) ...

Objective C: "EXC_BAD_ACCESS" error

Hi, I am a newbie, writing a simple program and while there are no warnings/errors during compilation. I am getting a "EXC_BAD_ACCESS" error. Will appreciate any help with this: int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; moviedatabase *movie1=[[moviedatab...

Ignore case UITextField/UITextView

Hi, I would like to ignore all case sensitivity to be ignored for my UITextField and UITextView. I would also like to know how to detect if the string is upperCase or lowerCase. Thanks. ...

How to reuse common subelements of a custom UITableViewCell with iOS Interface Builder?

I have several custom UITableViewCell, which share a lot of common subelements. I tried creating a UIView and using it as a subview for all the table cells, but obviously this wouldn't work, since entities in IB are object instances, not classes or templates. How can I capture these common subelements in a custom control and drag it i...

How to call the tap on the back-button in the UINavigationBar programmatically?

How to call the tap on the back-button in the UINavigationBar programmatically? ...

dealloc problem with instance variables

A problem happens when I was trying to release one of my instance variables and reassign it a new value. I would like to release the address that a instance variable points to, and re-assign a new value to it. The code look like this: The .h @interface MapPageController : UIViewController<MKMapViewDelegate> { AddressAnnotationManager...

How to draw a background fast in cocos2d?

I'm toying with a small game on my iPad using cocos2d and I've run into some performance worries. I have a 512x512 image tiled as my background. That gives me around 40fps with 20 sprites (in a CCSpriteBatchNode), the code for the background is this: CCSprite *background; background = [CCSprite spriteWithFile:@"oak.png" rect : CGRectMa...

How can I set the UITableView border with a grouped style

Does anyone know if it is possible to replace the grey border on grouped table view cells The opposite to this post: http://stackoverflow.com/questions/1408126/changing-border-color-in-iphone-uitableview-cells-non-grouped ...

how to subtract two dates in objective c

Hi, I have a problem. I want to subtract a date from currect date example: Result = Today - MySpeficied Date Can any one help me with a code snippet? Many Thanks. Best Regards, Naveed Butt ...

How to search NSMutableDictionary

Hi Friends. I have a simple question. How can I search NSMutable Dictionary? For eg. I have a dictionary like this: A1: Apple B1: Banana C1: Cat D1: Dog A2: Aeroplane B2: Bottle A3: Android Now i want to search all the content (values) whose key starting with letter "A", means I want to sear...