objective-c

Comparing a string to an array in objective-C

Dear all, here's a very basic question, that I'm sure you will be able to answer quickly. Please don't laugh at my ignorance. I have a string, that I want to compare to an array of strings. Only if the string is not part of the array, I want to perform an operation. I tried the following code, that doesn't work. I do understand why, bu...

resize uitableviewcell to the label's height dynamically ?

i want to resize cell's height according to the label's height and label's height according to text...?? or is there any way i can resize the cell's height according to the text entered in uitextview? ...

Saving an image to the users preferences

Has anyone had any experience in saving app preferences (within app, not in Settings app) which involve images taken with the camera? The prefs include NSStrings, UIImage, BOOLs etc. The UIImage is a pic taken with camera. Could I store these all in an NSMutableArray and then just do something like this: [array writeToFile:[self dataF...

How do I enable more handshake ciphers in CFStream?

When running the method: CFReadStreamSetProperty(theReadStream, kCFStreamPropertySSLSettings (CFDictionaryRef)tlsPacket->tlsSettings); To secure the connection of a CFReadStream, my iphone client returns the error: Error Domain=kCFStreamErrorDomainSSL Code=-9824 "Operation could not be completed. (kCFStreamErrorDomainSSL error -9824...

Calling a method in a subView

Hey guys! I have this little problem: I have one ViewController which adds 2 subViews in my ViewController so I have something like this: //in my viewController.m i have this: - (void)startIcons { IconHolder *newIconHolder = [[IconHolder alloc] initWithItem:@"SomeItenName"]; [self.view addSubview:newIconHolder]; } - (void)onPre...

Changing angle when ball hits paddle

I'd like to deflect a ball at an angle depending on where it hits a paddle. Right now, I'm only changing the y coordinate, which results in an uninteresting deflection. It will angle but independent on impact location against the paddle. I'd like something more fun. Speed, momentum, mass and other factors don't need to be taken into co...

Emacs mode question

I'm starting to use objective C, and objective C mode works perfectly fine. However, ObjC uses .h files, just like C and C++. I need to be able to use all three. Does anyone know how to get emacs to tell if it should be in objC mode or C/C++ mode? EDIT: There seems to be some confusion on what I'm asking for. The problem is that I have...

Filtering characters entered into a UITextField

I have a UITextField in my application. I'd like to restrict the set of characters that can be can be entered into the field to a set that I have defined. I could filter the characters entered into the field when the text is committed using the UITextFieldDelegate method: - (BOOL)textFieldShouldReturn:(UITextField*)textField However, ...

Why don't I declare NSInteger with a *

I'm trying my hand at the iPhone course from Stanford on iTunes U and I'm a bit confused about pointers. In the first assignment, I tried doing something like this NSString *processName = [[NSProcessInfo processInfo] processName]; NSInteger *processID = [[NSProcessInfo processInfo] processIdentifier]; Which generated an error, after t...

typedef enum type as key to NSDictionary?

Are enums not allowed as keys for an NSMutableDictionary? When I try to add to the dictionary via: [self.allControllers setObject:aController forKey:myKeyType]; I get the error: error: incompatible type for argument 2 of 'setObject:forKey:' Typically, I use NSString as my key name which doesn't require a cast to 'id' but to m...

How to play a tone on iPhone

Is it possible to easily play a tone, or series of tones on the iPhone (like morse code, beep beeeeeep beep)? Is there any sample code out there that would point me in the right direction? (I remember on the Commodore 64 it was about 4 lines of code !) ...

Objective-C Safari Fails - Too Many Redirects - LinkSynergy - iPhone

So, I'm working on an iPhone application that I hope to make my money off of via redirects to iPhone games using Apple's link synergy program. Problem is, the links are generating too many redirects and safari is saying "Safari can't open the page because too many redirects occurred". My code is quite simple: NSURL *toOpen=[NSURL URLW...

Customizing the iPhone keyboard

Is there a way to modify or make your own iPhone keyboard so that you can type in unsupported languages? ...

How to perform Callbacks in Objective-C

I am a beginner programmer in Objective-C. Can anyone please tell me how to perform call back functions in Objective-C. I would just like to see some completed examples and I should understand it. Thanks a lot ...

What does "MyIdentifier" mean in Objective-c or iPhone programming

I am puzzled at the following line "static NSString *MyIdentifier = @"MyIdentifier";" in the method: cellForRowAtIndexPath What does that line do? Is it just creating a random pointer to an NSString object and assigning it the string? Why is it being called MyIdentifier, I have seen this in many examples. #import "AddToFavorites.h" @...

Is this a job for NSTimer? Looping interface changes

A button on my inferface, when held down, will perform a series of changes on other parts of my interface. For instance, for one second some text will turn blue, then a UImageView will change its image for two secs ...etc etc... This series of changes will keep looping thru the same steps as long as the button is held down. I've neve...

How can I make deleteRowsAtIndexPaths: work with GenericTableViewController?

I'm using Matt Gallagher's GenericTableViewController idea for controlling my UITableViews. My datasource is a NSFetchedResultsController. http://cocoawithlove.com/2008/12/heterogeneous-cells-in.html Everything is working fine, until I try to delete a cell. I have the following code in my View Controller: - (void)tableView:(UITableVi...

Stalling in a game loop and removing sprites naturally

I'm making a game with cocos2d and I have a bunch of sprites that I would like to delete. For example I might have a bunch of characters on the screen but when my game is over I would like to clean them up. Right now I have created a special effect (particle system) as a distraction, but because it is transparent and does not cover all o...

Refreshing a UITableView

I have a UITableView subclass and a UITableViewCell sublass that I'm using for cells. I'm bulding all my cells in advance and store them in an array from where I use them in cellForRowAtIndexPath. Aside from this I have a thread that loads some images in each cell, in the background. The problem is that the cells don't get refreshed as f...

Change background color of NSButton

I have an NSButton in a mac application whose colour I'd like to change programatically but nothing I tried seems to work. I tried to create an output on the NSButtonCell and set the background color there but that didn't work either. Any code snippets would be helpful. ...