The following codes crashed:
@interface AppDelegate (PrivateMethods)
@property (nonatomic, strong) NSString * name;
@end
@implementation AppDelegate
- (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.name = @"foobar";
...
Error is:
'-[AppDelegate setName:]: unrecognized selector sent to instance 0x6d73df0'
When I change
@interface AppDelegate (PrivateMethods)
to
@interface AppDelegate ()
Then it is okay, what would be the reason?
Update: As answered below, since I must use class extension for this purpose, now this question become: Is the use of class extension to declare private methods acceptable?
e.g.
@interface AppDelegate ()
- (void) start;
@property (nonatomic, strong) NSString * name;
@end