I am novice in ios and I try to write a simple singleton object to share data between controllers. Here is my code:
#import <Foundation/Foundation.h>
#import "SynthesizeSingleton.h";
@interface BSStore : NSObject
+(BSStore *)sharedStore;
@property (nonatomic,strong) NSArray *sharedNotebooks;
@end
#import "BSStore.h"
@implementation BSStore
SYNTHESIZE_SINGLETON_FOR_CLASS(BSStore)
@synthesize sharedNotebooks;
@end
//Write Objects in AppDelegate
[BSStore sharedStore].sharedNotebooks = notebooks;
//Read objects in a ViewController
Notebook *notebook = [[BSStore sharedStore].sharedNotebooks objectAtIndex:indexPath.row];
and I get:
2012-10-04 02:01:29.053 BarneyShop[1827:f803] +[BSStore sharedStore]: unrecognized selector sent to class 0x69b8
2012-10-04 02:01:29.073 BarneyShop[1827:f803] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[BSStore sharedStore]: unrecognized selector sent to class 0x69b8'
*** First throw call stack:
This is what your Singleton class should look like:
Now you can call: