I have one problem. RestKit I use in my application. When I receive data over the network, I keep them in the object and then use the various fields of the class. In my case I get an article in which there is a field of URL, which is used in UIActivity to send a link in the social network. When I call handler function pressing UIAсtivity I get the URL is NULL. I can not understand why this happens.
NewsDetailViewController.h
@property (nonatomic,strong) NSString *URL;
NewsDetailViewController.m
@interface NewsDetailViewController() {
NSString *URL;
}
@synthesize URL;
[[RKObjectManager sharedManager] getObjectsAtPath:route parameters:params
success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
Article *article = [mappingResult.array firstObject];
self.URL = article.url;
}
failure:^(RKObjectRequestOperation *operation, NSError *error) {
NSLog(@"Error response': %@", error);
}];
-(void)socialSharing:sender {
dispatch_queue_t queue = dispatch_queue_create("openActivityIndicatorQueue", NULL);
dispatch_async(queue, ^{
NSArray *itemsToShare = @[self.URL];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:itemsToShare applicationActivities:nil];
if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) {
activityVC.excludedActivityTypes = @[UIActivityTypeAirDrop];
}
dispatch_async(dispatch_get_main_queue(), ^{
[self presentViewController:activityVC animated:YES completion:nil];
});
});
}
init button
_items = [[self.toolBar items] mutableCopy];
UIBarButtonItem *shareBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(socialSharing:)];
[_items addObject:shareBtn];
[self.toolBar setItems:_items animated:YES];
Inside function socialSharing:sender my variable self.URL is NULL. I don't understand why?