1

I am new for learning objective-c

when I learned about protocol and delegate, I can't fix this reference error.

How should I modify my code?

Or my concept is wrong about coding objective-c

I tried to know declare a object(Info) in another object(InfoUser),

but seems not the question .

It seems I can handle property like this.

#ifndef Info_h
#define Info_h

@protocol InfoDelegate <NSObject>

-(void) initFn;

@end

@interface Info : NSObject

@property (nonatomic, weak) id<InfoDelegate> delegate;

@end


#endif /* Info_h */

#ifndef InfoUser_h
#define InfoUser_h

@interface InfoUser : NSObject


@end

#endif /* InfoUser_h */

#import <Foundation/Foundation.h>
#import "Info.h"
#import "InfoUser.h"

@interface InfoUser ()<InfoDelegate>
@property  (nonatomic, strong) Info *infocase;

@end


@implementation InfoUser

-(instancetype) init {
     self.infocase =  [[Info alloc] init];
     self.infocase.delegate = self; 
     return self;
}


- (void)initFn {
     NSLog(@"initFn");
}

@end

here is the error message

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_Info", referenced from:
      objc-class-ref in InfoUser.o
      (maybe you meant: _OBJC_CLASS_$_InfoUser)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see 
invocation)

Does any one can tell me how to fix ?

thanks

ps. sorry this is the first time I post for question? If any thing I didn't notice,please tell me.

BIllyLiu
  • 11
  • 3

0 Answers0