views:

64

answers:

1

Can we access the integer type variables in classB which are declared in classA by not using extern?

For objects I used ClassA *obj1 = [[ClassA alloc]init]; And accessed the objects of classA into class B.

But, I am not able to do them with the int , float, NSTimeInterval. How can we do for them without using extern ?

Thank You.

A: 

I think you can just declear it in the interface like:

@interface NCItem : NSObject {
  @private
    UIImage *image;        
    NSNumber *highestPrice;        
    NSMutableArray *services;
}

@property (nonatomic, retain) UIImage *image;    
@property (nonatomic, retain) NSNumber *highestPrice;

and in the implementation file:

@synthesize highestPrice;
@synthesize services;
@synthesize image;

and you can use this in class B:

ClassA *objA = [[ClassA alloc]init];
objA.image

These things are all OOP is about What is preventing you to do so?

vodkhang
Hi,I have no problem with UIImage, CCSprite or NSMutableArray. I am declaring variables in int, float types. And I have variables of NSTimeIntervals. All these do not have * before them. So, I think I could not access the values. Can we do with these types too.Thank You.
srikanth rongali
Yes, you can do that. I tried with BOOL, although it is a signed char, but I think it will be the same as, int, float ...
vodkhang
Thank you. I will do it. And I post if I have any errors or problems.
srikanth rongali