在SecondViewController中使用过块。创建块作为属性并添加了复制属性。但是,当它达到**self.didSelectImageInImagePickVC(name);**
SecondViewController.h
@property (nonatomic, copy) void(^didSelectImageInImagePickVC)(NSString *imageName);
SecondViewController.m
NSString *name = [resultArray objectAtIndex:indexPath.item];
self.didSelectImageInImagePickVC(name);
Firstviewcontroller.m
__typeof(&*self) __weak weakSelfImagePick = self;
[[SecondViewController sharedInstance] setDidSelectImageInImagePickVC:^(NSString *imageName){
NSLog(@"Image: %@", imageName);
}];
有没有人有任何想法?提前谢谢。
答案 0 :(得分:0)
尝试访问secondViewController的存在块,如下所示。
有问题你的是创建新块
[SecondViewController sharedInstance]. didSelectImageInImagePickVC = ^(NSString * imageName) {
// here your image name
};
或
你需要为你的类的块属性分配参数块。
-(void)setDidSelectImageInImagePickVC:(yourblock)block{
self.didSelectImageInImagePickVC = block
}