我有以下非ARC代码
int sortMidiEvent(void* v1, void* v2) {
MidiEvent **ev1 = (MidiEvent**)v1;
MidiEvent **ev2 = (MidiEvent**)v2;
MidiEvent *event1 = *ev1;
MidiEvent *event2 = *ev2;
if (event1.startTime == event2.startTime) {
return event1.eventFlag - event2.eventFlag;
}
else {
return event1.startTime - event2.startTime;
}
}
我想将其转换为ARC。我该怎么办?
我可以更改为以下内容吗?
int sortMidiEvent(void* v1, void* v2) {
MidiEvent *event1 = (__bridge MidiEvent *) v1;
MidiEvent *event2 = (__bridge MidiEvent *) v2;
if (event1.startTime == event2.startTime) {
return event1.eventFlag - event2.eventFlag;
}
else {
return event1.startTime - event2.startTime;
}
}
我不明白为什么我们需要指向非ARC的指针?