objective-c

xCode / declaring Static Methods in class

Anyone know how I can declare a static method for an xcode class and then use it in my project? I want to create a Common.h class and then do something like this in one of .m file Common.MyStaticMethod(); I dont want to have to instantiate and instance of Common ...

Is there an advantage on the iPhone to breaking up an operation into multiple threads?

I have a method in my iPhone app that is very repetitive (called over and over and over sequentially). The method is quite bulky and takes about one second to complete. My question is this: If I was to muti-thread it to run, say 5 method calls on different threads simultaneously, would that be any faster than running 5 calls one after ...

How to update cocos2d?

I've been using an older version of cocos2d for iPhone for an existing project - never change a running system. Now I'd like to upgrade to a more recent version and don't know how I should proceed about this. Just install a newer version? Will the install script overwrite all of the old files and take care of the old templates too? Or d...

Add suffix to file name before extension

What's the simplest way to add a suffix to a file name before the extension in Objective-C? Example Original name: image.png Suffix: ~ipad Result: image~ipad.png ...

Write/Read plist file iPhone

Hi I have plist in my iphone app and I want to read and write an integer from my single to and form it. I have this to read it: scoreData *score = [scoreData sharedData]; filePath = @"stats.plist"; NSMutableDictionary* plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:filePath]; score.highScore = [plistDict object...

Objective-C "const" question

Wikipedia says "const" is "...a special kind of variable whose value cannot typically be altered by the program during its execution..." If that is the case, why does this: const char *words[4] = { "aardvark", "abacus", "allude", "zygote" }; *words = "first"; words[1] = "second"; int wordCoun...

Strict vs loose typing when overriding a method

I have a class called AddressCard from an example in "Programming in Objective C", and I'm implementing a isEqual: method. The signature of this method in NSObject uses loose typing for the parameter: - (BOOL)isEqual:(id)anObject OTOH, the sample code in the book uses strict typing: - (BOOL) isEqual:(AddressCard *) aCard I'm not s...

How can I make an object disappear on the Mac?

So basically I just want to have the user click on an NSButton, and have it disappear once it is clicked. How can I do that? ...

#pragma mark text field delegates

what is this #pragma mark text field delegates? It is like a comment? or what is this used for? ...

NSObject inherited class crashes the application

Hi all! I'm new in objective-C and here is my problem: I want to write a game and i want to use a GameStateManager class to manage the game states. As i've read every class in Objective-C should be inherited from NSObject or it's subclass. So here is the GameStateManager interface: @interface GameStateManager : NSObject { int curren...

encrypt a file on iphone-sdk

Hello, I'd like to have a file encryption functionality for my iphone application. For desktop based applications i used the function below to encrypt relatively small files: - (NSData *)aesEncrypt:(NSString *)key { // 'key' should be 32 bytes for AES256, will be null-padded otherwise char keyPtr[kCCKeySizeAES256+1]; // room for term...

regexkitlite match ?

Hi, i would like to get everything inbetween &v= and "> using a regex expression, NSString *YouTubeRegex = @"/amp;v=([^(\">)]+)/"; But that regex is not returning any matches ? i know the coding is correct just not the regex expression any help ? Thanks ...

frame size and coordinates off (objective-c, ipad)

Supposedly this is a 10 by 10 square 100 pixels on the x axis from the origin and 100 pixels on the y axis from the origin (origin being the top left corner) However it quite clearly wrong. Writing the views frame to NSLog after setting it gives out the same values I put in. Code: ISScrollDock *bottomSV = [[ISScrollDock alloc] init];...

ViewDidAppear/ViewWillAppear not being called

I have a ViewController that adds to other subviews which have subclassed uiviewControllers so Its like this: mainViewController | v---------v subVC1 subVC2 And neither subVC1 or subVC2 have the viewDidAppear/viewWillAppear fired on them? The main view controller is creating in the app delegate and it view added there as w...

Compare a NSNumber to an int

Hi! I've a simple question (I think): I'm trying to compare a NSNumber with a int, to see if it is 0 or 1. Here is the code: id i = [dictionary objectForKey:@"error"]; //class = NSCFNumber NSLog(@"%@ == 0 -> %@", i, i == 0); NSLog(@"%@ == 0 -> %@", i, [i compare:[NSNumber numberWithBool:NO]]); I tried this to methods but I get null a...

resize and crop image centered

Hi, so currently i'm trying to crop and resize a picture to fit it into a specific size without loosing the ratio. a small image to show what i mean: i played a bit with vocaro's categories but they don't work with png's and have problems with gifs. also the image doesn't get cropped. does anyone have a suggestion how to do this re...

Strange iPhone NSTableView cell.textLabel.text Bug?

Hey guys, I'm working with a UITableViewController, and I have a section of code as follows: Subject *subject = [[context subjects] objectAtIndex:[indexPath row]]; cell.textLabel.text = [subject name]; cell.showsReorderControl = YES; return cell; This code is in the UITableViewDataSource method that returns an UITableViewCell for an...

Why is there a call to the superclass inside of many methods in Objective-C?

Hello! I wonder why in these examples there is always a [super someMethod] inside of the Method that has the exact same name: - (void)viewDidLoad { [super viewDidLoad]; // some code } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } - (void)viewDidUnload { [super viewDidUnload]; } I know that t...

iPhone dev - how to create a hyperlink?

How do you create a hyperlink? (iPhone dev) ...

How to add share via email option in my iphone app

I want to add a feature of sending some text via email from my iphone app. please tell me how to proceed. plz tell the steps on how to send email from and to . thanks ...