遷移自開源中國
// 定義結構體
struct NoteGroup {
CGRect rect;
int page;
};
typedef struct NoteGroup NoteGroup;
// 存入集合
NoteGroup noteGroup = {rect, 3};
[array addObject:[NSValue valueWithBytes:¬eGroup objCType:@encode(NoteGroup)]];
// 取出
NoteGroup noteGroup;
NSValue *noteGroupValue = array[index];
[noteGroupValue getValue:¬eGroup];