-5

classOne.h followed by classOne.m

@interface classOne : NSObject
   @property int xyz;
@end

#import "classOne.h"
@implementation srModel
    @synthesize gameType;
@end

classTwo.m

#import "classOne.h"
@implementation classOne
classOne *ClassOne;
ClassOne.xyz=99;
@end

when I debug the program its still showing xyz as nil. Am I doing this correct? I'm new to objective C.

Balaji Kandasamy
  • 4,446
  • 10
  • 40
  • 58
user2573339
  • 138
  • 6
  • 4
    You need to initialize `classOne` – Bhumeshwer katre Feb 10 '14 at 08:58
  • 1
    Page 1 of any book about Objective-C programming for beginners will answer this. Stack Overflow is NOT the place for stuff like this. Having said that, this is one of the most commonly asked questions on Stack Overflow so a little bit of searching would have found the answer. – Fogmeister Feb 10 '14 at 09:02
  • 1
    why not read some VERY VERY basics before starting coding??? How are you going to perform difficult tasks if you do not read even about simple things??? – Andrey Chernukha Feb 10 '14 at 09:07
  • 1
    If you're new to ObjC, asking questions on Stack Overflow is not the place you need to be. You should find a good book or a series of online tutorials. Have a look at [Good resources for learning ObjC](http://stackoverflow.com/q/1374660). The Big Nerd Ranch books are excellent, and lots of people like the Stanford iOS course on iTunes U. Good luck! – jscs Feb 10 '14 at 09:13

1 Answers1

2

You have to alloc first as below :

classOne *ClassOne = [[classOne alloc] init];
ClassOne.xyz=99;

Now it would get resolved

Samkit Jain
  • 2,523
  • 16
  • 33