简体   繁体   中英

Running the project by build is not working in MAC OSX 10.7

-(void)artworkImages{
NSArray *noOfSongs = [mySongsArray content];
for (int i=0; i<[noOfSongs count]; i++) {
    NSDictionary *dic = [[NSDictionary alloc] init];
    dic = [[mySongsArray arrangedObjects] objectAtIndex:i];
    NSURL *url = [NSURL fileURLWithPath:[dic objectForKey:@"Path"]];
    AVURLAsset *asset = [AVURLAsset URLAssetWithURL:url options:nil];
   for (NSString *format in [asset availableMetadataFormats]) {
        for (AVMetadataItem *item in [asset metadataForFormat:format]) {
            if (i>240 && i<250) {
                NSBeginAlertSheet(@"Check the loop", @"Delete", nil, @"Cancel", window, self, @selector(alertEnd:returnCode:cInfo:), NULL, nil, @"format===%@,%d",format);
            }
        }
   }
}

}

Above methods is working fine if I run the project by Code (X code), but getting issue if I run by build. I am importing songs from iTunes library.xml, after that I am storing into NSArrayController . Here in this method I am trying to fetch artwork images but if I run by build I am getting around 250 images out of 400.

Without the code of alertEnd:returnCode:cInfo: it's hard to tell, but it generally appears like something in that function is killing the for loop.

What exactly are you trying to achieve with:

            if (i>240 && i<250)

Can you post the code for the 'alertEnd:returnCode:cInfo'. Also it would probably be easier to read if you used a __block for alert sheets. If the alertEnd:returnCode:cInfo isn't referred to more than once, I'd keep it as a block. If you reuse the code within alertEnd:returnCode:cInfo then promote it to it's own void/function.

some possibilities:

  • you are importing/reading a different "iTunes library.xml" file that was created with a smaller set of itunes files. and maybe that filename is set in the xcode arguments???

  • [noOfSongs count] has an inconsistent value, because objects are removed from noOfSongs

try :

NSInteger *cntSongs = [[mySongsArray content] count];
for (int i=0; i< cntSongs; i++) {

rather than the current:

NSArray *noOfSongs = [mySongsArray content];
for (int i=0; i<[noOfSongs count]; i++) {
  • mySongsArray is shadowed by another property of the same name. see -Wshadow.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM