My Custom Delegate (With Share Object) call back is not working? I pasted the code below ...
ViewController.h
#import <UIKit/UIKit.h>
#import "UserLocation.h"
@interface ViewController : UIViewController
@end
ViewController.m
#import "ViewController.h"
@interface ViewController () @end
@implementation ViewController
- (IBAction)fetchLocation:(id)sender{
UserLocation *obj = [UserLocation new];
[[UserLocation LocationObject] FetchLocation];
}
@end
UserLocation.h (Custom Delegate File)
#import <Foundation/Foundation.h>
@protocol UserLocationDelegate <NSObject>
-(void)userLocationCallBack;
@end
@interface UserLocation : NSObject <UserLocationDelegate>
{
// Delegate to respond back
}
+ (UserLocation *) LocationObject;
+ (void)removeSharedHelper;
- (void)FetchLocation;
@property (nonatomic,strong) id<UserLocationDelegate>UserLocationDelegate;
@end
UserLocation.m
#import "UserLocation.h"
@implementation UserLocation
static UserLocation * _sharedActivityObject;
+ (UserLocation *) LocationObject
{
if(_sharedActivityObject != nil){
return _sharedActivityObject;
}
_sharedActivityObject = [[UserLocation alloc] init];
[_sharedActivityObject initializeActivityView];
return _sharedActivityObject;
}
+ (void)removeSharedHelper {
if (_sharedActivityObject != nil) {
_sharedActivityObject = nil;
}
}
-(void)initializeActivityView{
}
- (void)FetchLocation{
[_UserLocationDelegate userLocationCallBack];
}
-(void)userLocationCallBack
{
NSLog(@"Good");
}
@end
What mistake did I do?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…