初探lottie-ios 动画的使用 之 属性block回传用法

当点击单元格时 调用block传值的属性

  • (回传属性 如下图)
#import 

@interface JSONExplorerViewController : UIViewController

@property (nonatomic, copy) void (^completionBlock)(NSString *jsonURL);

@end
  • 点击时激发下面的方法
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
  NSString *fileURL = self.jsonFiles[indexPath.row];
      //为所获取到的 本地文件路径 末尾拼接一个  "  \  " 
      //使用字符串替换可以事后弥补:[jsonString stringByReplacingOccurrencesOfString:@"\\" withString:@""];
  NSArray *components = [fileURL componentsSeparatedByString:@"/"];
    
   if (self.completionBlock) {
    //通过当前去调用 URL block传值的 属性
    self.completionBlock(components.lastObject);
       
       //所点击的 单元格行内容 并输出 通过文件路径,且获取到的最后一个对象元素
       NSLog(@"\n===n%@===\n====%ld\n",components.lastObject,(long)indexPath.row);
       
  }
}
  • 点击导航条的 “关闭” 按钮时 调用的方法、
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"关闭" style:UIBarButtonItemStyleDone target:self 
 action:@selector(_closePressed)];
  • "关闭“ 触发的方法 —— (不返回 任何 数据即可。 写 nil )
- (void)_closePressed {
    
  if (self.completionBlock) {
    self.completionBlock(nil);
  }
    
}

你可能感兴趣的:(初探lottie-ios 动画的使用 之 属性block回传用法)