this is something I have always had confusion about
I never can seem to find a good explanation, i understand inheritance, but from what i learned that is between the master class and the sublasses of them…What if i want to pass a NSString to another class thats not a subclass of the other
Heres a example:
class1.h
@interface class1 : UIViewController{
NSString *string
}
@property (nonatomic, retain) NSString *string
@end
class1.m
@implementation class1
@synthesize string;
-(void)viewDidLoad{
string = @"IM A STRING AHHH";
}
Now lets say i want to pass that string with what its equal to to another class
class2.h
#import "class1.h"
@interface class2 : UIViewController{
}
@end
class2.m
@implementation class2
//i want to use the NSString in here, how do i do that?
Thanks,
Jacob
First of all use
[string retain];in class 1.Then, in class 2, import class1. make object of class 1 say cls1. and you can access it by
cls1.string;