-1

EXEC_BAD_ACCESS(Code=1 , Address 0x0)此代码在 Appledelegate.m 之后applicationDidFinishLaunching。在while循环中随意随机发生(如果find事件很少,也不例外)。对不起语言,感谢任何帮助我......现在来源:

int trackindex = 14;
MusicSequenceGetIndTrack(sequence,trackindex, &track);

// Iterate throught the select track and add user event
Boolean hasNextEvent = false;
Boolean hasEvent = false;
NewMusicEventIterator(track,&iterator);
MusicEventIteratorHasCurrentEvent(iterator, &hasEvent);
MusicEventIteratorHasNextEvent(iterator, &hasNextEvent);

// loop throught track
while (hasNextEvent==true){
    MusicTimeStamp timestamp = 0;
    MusicEventType eventType = 0;
    const void *eventData = NULL;
    int note = 0;
    MusicTimeStamp duration = 0;
    MusicEventIteratorGetEventInfo(iterator, &timestamp, &eventType, &eventData, NULL);

    if(eventType == kMusicEventType_MIDINoteMessage) {
        MIDINoteMessage *noteMessage = (MIDINoteMessage *)eventData;
        note = noteMessage->note;
        duration = noteMessage->duration;
        UserEvent event;

        event.lenght = 0;
        event.lenght = sizeof(UserEvent);
        event.playedNote = note;
        event.tStamp = timestamp;

        MusicEventUserData *data = (MusicEventUserData *)&event;
        MusicTrackNewUserEvent((MusicTrack)track, timestamp, data);

        counter++;
        printf("counter : %u\n",counter);
    }

    MusicEventIteratorHasNextEvent(iterator, &hasNextEvent);
    MusicEventIteratorNextEvent(iterator);
}
4

1 回答 1

0

引起我注意的第一件事是“while (hasNextEvent==true)”与“while (hasNextEvent)”不同。

第二个是,在循环结束时,您获取迭代器的“hasNextEvent”然后在检查状态之前将其推进似乎很奇怪。不确定它是错的,但它看起来是错误的。

于 2012-09-19T20:25:23.217 回答