objective-c

Minimum steps to display a table-view in Cocoa OSX

Hi I am trying to create a table-view programatically using a cocoa lisp bridge called clozure CL. Now I doubt many people are familiar with this package so I will not go into specifics of my code but I am getting some very strange errors when I try to call addSubview to add my tableView to my window. I have initialized it using InitWi...

how can I create unlimited UIImageViews with a Button press of which I can address any later?

Hello, I want create a UIImageView with a button press. I did this with: - (IBAction) addPicture:(id)sender { imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0.0, 45.0, 324, 52.0)]; imageView.image = [UIImage imageNamed:@"Picture.png"]; [self.view addSubview:imageView]; } I "created" this imageView in the .h, beca...

Custom Modal Window with Block Completion Handler

Hey Guys! I'm stuck! I am trying to create a custom modal dialog. I would like it to perform similarly to the NSSavePanel using a block as a completion handler. I've copied only the important snippets I think are needed. @implementation ModalWindowController - (void)makeKeyAndOrderFront:(id)sender modalToWindow...

Is there an ideal transfer format for iphone web services?

I'm designing the back-end for an iphone application. I'd like to use Core Data. Is there an ideal transfer format for iphone apps? I'm leaning towards JSON unless there's some custom binary thing. I'm probably using ruby on the backend. For example, in the Flex/Flash world, you can install a small piece on your server that lets you se...

UIColor/RGB Way to go from X Color to Y Color

Hi All I wonder if anyone could suggest the best way to go from one color to another in a gradual process. So - I have a text box which I have a text limit on. I'd like to have the text start at white, but be red by the time it gets to the max text limit. Is there an easy way to do this? I'm unsure really where to start... ...

How can I detect which UIImageView was selected with a touch in touchesBegan?

Hello, The user can create a unlimited number of UIImageViews with a button press with this code: - (IBAction) addPicture:(id)sender { imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0.0, 45.0, 324, 52.0)]; imageView.tag = a; imageView.image = [UIImage imageNamed:@"Picture.png"]; a = a + 1; [self.view addS...

My UIImageView doesn't get all the methods of my subclassed UIImageView

Hello, I created a subclass (called MyPicture) of the UIImageView with this methodes: - (id)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { self.userInteractionEnabled = YES; } return self; } - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@"-- I AM TOUCHED --"); }...

for each loop in objective c for accessing NSMutable dictionary

I am finding some difficulty in accessing mutable dictionary keys and values in Objective-C. Suppose I have this: NSMutableDictionary *xyz=[[NSMutableDictionary alloc] init]; I can set keys and values. Now, I just want to access each key and value, but I don't know the number of keys set. In PHP it is very easy, something as follows...

How do you set the name of the iPhone app ?

Hi, I have released and updated a few apps now, but this is still not very clear. The app name as it appears on the app store is set from iTunes connect. Where do you set the name of the app as it appears on the phone once it is installed? I have tried and succeeded in setting it in 'Product Name', but when Product Name has a space in...

How can I best deal with problems when initializing a model in an iphone app?

So assume I have a class that has an init method that does something like... grabs some data off the net in xml format and parses it to initialize some of its properties. My concern is how should I handle the case where the network is down or the xml data my object receives is bad? Normally in C i would use return values to indicate an...

Best way to see if a song exists in iPod Library

Hello, What is the best way to see if a song exists in the iPod library? I am currently doing the following: MPMediaQuery *query = [[MPMediaQuery alloc] init]; [query addFilterPredicate: [MPMediaPropertyPredicate predicateWithValue: artist forProperty: MPMediaItemPropertyArt...

reading an array

I create random numbers using the following code and store them in an array. NSMutableSet *aSet = [NSMutableSet setWithCapacity:6]; while([aSet count]<=6){ int Randnum = arc4random() % 12; [aSet addObject:[NSNumber numberWithInt:Randnum]]; } NSArray *arrayOfUniqueRandomNumbers = [aSet allObjects]; Now, I need to read the ...

What is the Objective-C equivalent to main()?

Hi everyone! I'm just a beginner at Objective-C and its syntax is just knocking me out of my mind. I'm 'trying' to work on iphone 3.0. Up till know I have learned that: there is .h file which contains the declaration for every class; like we have in C++ where we can declare the name of the variables/data_fields and later define the...

How do I free() after malloc() when the result of malloc() is returned by the function?

I have the following instance method (adapted from Listing 3-6 of the Event Handling section in the iPhone Application Programming Guide): - (CGPoint)originOfTouch:(UITouch *)touch { CGPoint *touchOriginPoint = (CGPoint *)CFDictionaryGetValue(touchOriginPoints, touch); if (touchOriginPoint == NULL) { touchOriginPoint...

App freeezes when playing sound with AVAudioPlayer

Hi! I am making an app for preschoolers with several mini-games. One of them involves finding "what is wrong" in the picture. For example if they press the kid playing in the street, a pling sounds, the child is moved out the street, and a label is updated to "1/5 errors found". If they find them all, they move on to a new viewcontrolle...

Why are objects added this way? I understand the math. I don't understand why the instance variables of the object being passed in have to be accessed using the dot notation.

-(void) addFractions: (Fraction*) f { numerator = numerator * f.denominator + denominator *f.numerator; denominator = denominator *f.denominator; } //This is objective c-2.0 // this is the .h file for the .m above -(void) addFractions : (Fraction*) f; Don’t forget that you can refer to the Fraction that is the recei...

How to create a damage bar for a shooting game on iPhone?

Hi everyone I have a question in game development. I am building a game for iPhone. At the game play, there is a damage bar, that displays what the player has damage the enemies. The technique I use is using 2 pictures. One is a damage bar which is fill with full damage, and one is jus a black bar but same size with the damage bar. It i...

How to test InAppPurchase In itunes connect

In My application we add InAppPurchase application with MKStoreObserver.h and .m file and MKStoreManager.h and .m file in my app. we want to test my this as transaction is done or not how to do this. ...

How to get devicetoken of iphone for push notification?

Hi everybody, I am trying to use the push notification service provided by apple but I am not able to get the device token required for pushing the notification. I am using the following code for retrieving the device token - (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken { co...

how to set the annotation to many place of search result in objective-c for iphone

I want to set the annotation to the all place of search result of google map. but i am getting the only single annotation at single point of search result. - (IBAction) showAddress { [addressField resignFirstResponder]; MKCoordinateRegion region; MKCoordinateSpan span; span.latitudeDelta=1; span.longitudeDelta=1; CLLoc...