I’m trying to pass data around objects using singleton pattern. Here is my code
SearchData.m
@implementation SearchData
@synthesize theName = _theName;
-(id)init
{
if(self = [super init])
{
_theName = @"Default";
}
return self;
}
static SearchData *sharedSingleton = NULL;
+(SearchData *)sharedSearchData
{
@synchronized(self)
{
if (sharedSingleton == NULL)
{
sharedSingleton = [[self alloc]init];
}
return sharedSingleton;
}
}
@end
FirstView.m
…
-(id)init
{
if (self = [super init])
{
SearchData *data = [SearchData sharedSearchData];
self.aName = [data theName];
}
return self;
}
…
The problem is that I get
Incompatible pointer types sending NSString to parameter of type NSStream.
What is wrong here ?
How to pass data to aName ivar ?
In your declaration of
aName, did you mistypeNSStringasNSStream? Stranger things have happened.