用Java语言来说,OC中的Block有着类的感觉。但OC的类与block又有着不同之处,OC的类有.m
和.h
文件,即@interface
与@implementation
。而Block
却没有类,但是它有着属性。举个Block例子:
Bock基础用法:
#import <Foundation/Foundation.h>
struct Books {
NSString *title;
NSString *author;
NSString *subject;
int book_id;
}
int main(){
struct Books Book1;
Book1.title