Writing a class works as a pass-through value
#import <Foundation/Foundation.h>
@interface Singleton:nsobject
+ (singleton *) Sharedata;
@property (Strong, nonatomic) NSString *value;
@end
#import "Singleton.h"
@implementation Singleton
static Singleton *singletondata = nil;
+ (Singleton *) Sharedata {
Static dispatch_once_t Oncetoken;
Dispatch_once (&oncetoken, ^{
Singletondata = [[Singleton alloc] init];
});
return singletondata;
}
-(ID) init {
if (self = [super init]) {
}
return self;
}
@end
If you're going to pass the value from a to B ,you're going to assign value to
Singleton *ones = [Singleton sharedata];
Ones.value = @ "My name is Caomao";
NSLog (@ "ones.value---->%@", ones.value);
The value has been assigned ...It's OK to call out in the class you needThis is a call in class B
NSString *STRB = [singleton sharedata]. value ];
IOS Single-Pass value