开发者

incompatible type for argument in Objective-C - what am I doing wrong?

开发者 https://www.devze.com 2023-01-26 06:01 出处:网络
I can\'t spot what I\'m doing wrong here. I have 2 classes, harness and audioplayer. In the audioplayer header I have declared m开发者_JS百科y function like so.

I can't spot what I'm doing wrong here.

I have 2 classes, harness and audioplayer.

In the audioplayer header I have declared m开发者_JS百科y function like so.

- (void) loadAudioFileIntoMemory:(NSURL *)address channel:(int) value row:(int) value2;

// In the audioplayer implmentation file my function is like so.

- (void) loadAudioFileIntoMemory:(NSURL *)address channel:(int)value row:(int)value2
{

 //NSLog(address);
}

When I try to call the function in the following way I get an incompatible type for argument error. (audioPlayer is a member of harness by the way and the line below is from harness)

[self.audioPlayer loadAudioFileIntoMemory:rawurls[count] channel:0 row:0]; 

EDIT 1 for clarity

This is how I am defining my raw url array

rawurls= [[NSMutableArray alloc] initWithCapacity:16];
    // Create the URLs for the source audio files. The URLForResource:withExtension: method is new in iOS 4.0.
    NSURL *loop0   = [[NSBundle mainBundle] URLForResource: @"FHP_EFFECT25_C.mp3"
                                                withExtension: @"mp3"];

[rawurls addObject:loop0]


You do not access the objets in an NSArray with C style subscripts.

You need to do this:

[self.audioPlayer loadAudioFileIntoMemory:[rawurls objectAtIndex: count] channel:0 row:0]; 


The problem here is that you are written your code as is rawurls was of type **NSURL - i.e. an array of pointers to NSURLs. In fact from your final example, it's of type NSArray.

Subscript operators don't work on NSArrays - this is Objective-C not c++.

Here's how to subscript an NSArray:

(NSURL*)[rawurls objectAtIndex:count]
0

精彩评论

暂无评论...
验证码 换一张
取 消