Synthesize is not working and basic operations are not working in Objective-C?

I have a feeling something's wrong with the way you're using int r Try putting static int r at the top of the interface line in MainView. H and also add, under the (IBAction)buttonclick line: (void) initialize Then remove int r from MainView.m. Then in MainView.

M add: (void) initialize { count = 0; }.

I have a feeling something's wrong with the way you're using int r. Try putting static int r; at the top of the @interface line in MainView. H and also add, under the - (IBAction)buttonclick; line: +(void) initialize; Then remove int r; from MainView.m.

Then in MainView. M add: +(void) initialize { count = 0; }.

Or just make r a real ivar: add it to the variables declared in the @interface, initialize it to 0 in -init, and then increment it in buttonClick. – Sixten Otto Nov 3 '09 at 2:55 Oh, that's another way of doing it :) – Jorge Israel Peña Nov 3 '09 at 2:56 @Sixten Otto: you don't need to use initialize r. It is set to 0 in the alloc.

– Abizern Nov 3 '09 at 11:07 @Abizern I just knew someone was going to jump on that. :-) Yes, the runtime will zero out ivars when allocating the memory, so that part isn't strictly necessary. – Sixten Otto Nov 3 '09 at 17:50 Thanks for the help but now it says "expected special-qualifier-list before static" under the "#import "MainView.

H" line. It also says that "r" is still undeclared! – jackson Nov 3 '097 at 23:16.

I see two issues: You can't declare int r where you have it. You should declare it in your interface's variable block (where you declare your button and labels or outside a method) or in the method definition. The line with r++ isn't ended with a semi-colon.

You don't say in your question what, exactly, isn't working the way you expect it. My guess is going to be that your outlets aren't actually connected properly. You might want to add a log statement to buttonClick like this: NSLog(@"button click called!

MyTextLabel is %@", MyTextLabel); The point being, mostly, to be sure it isn't nil.

Sorry, for not telling! The code stalls and stops on opening the app and in the code it stops on the "@synthesize" – jackson Nov 3 '09 at 2:20 Can you add the stack trace in the original question? – nall Nov 3 '09 at 2:46.

In Objective-C the names of variables and properties must start with a lowercase letter to conform to the Key-Value Coding (KVC) protocol (always myButton, never MyButton). The @synthesize directive relies on this to generate the setters and getters. Thus, for myButton @synthesize will generate -(void)setMyButton:(UIButton *)button and -(UIButton *)myButton.So, do make MyButton and its colleagues lowercase and see if it helps.

Action methods always have a sender argument, so your -buttonClick: method should be declared like this: -(IBAction) buttonClick: (id)sender { }.

Nonatomic is described in detail here. Retain means that the property is retained when the value is set to anything other than nil. There are other options such as copy and assign.

Normally object types that can be copied should use copy, like NSString. Assign simply sets the pointer value. @synthesize stubs out the getter and setter methods for the property and is required in order for the nonatomic and retain to work.

Also, make sure that if you use retain or copy, that you also release the object in the dealloc method.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions