0
votes

I try to use a Swift class in Objective C and let the Objective C class "GameScene" receive delegate calls from the swift class. But from within the swift class I get the error "Cannot Invoke drawTopEdge with an argument list of type '(int, col:int)'

    //above in the code
    var maze:[[Int]]!
////////////////
     func display() { //this is in the swift class
        for i in 0..<y {
            // Draw top edge
            for j in 0..<x {
                print((maze[j][i] & 1) == 0 ? "+---" : "+   ")
                if ((maze[j][i] & 1) == 0) {
                   delegate!.drawTopEdge(j, col: i) //Error see picture attached and above
                }
            }


    //This is in the GameScene class
    -(void)drawTopEdge:(NSUInteger)r col:(int)c; 
    -(void)drawLeftEdge:(NSUInteger)r col:(int)c;
    -(void)drawBottomEdge:(NSUInteger)r col:(int)c;

http://i.stack.imgur.com/dVLEe.png

enter image description here

1
did you attach picture?Teja Nandamuri
int is different than nsuinteger. Did you try by making all int?Teja Nandamuri
Everything is already in int isn't it?cocos2dbeginner
but one of the method parameter is nsuintegerTeja Nandamuri
Ah thanks for the notice. I did change it but I still get the same error.cocos2dbeginner

1 Answers

0
votes
-(void)drawTopEdge:(NSUInteger)r col:(int)c; 

NSUInteger becomes Int in Swift. However, int becomes CInt. Ideally you should change your signatures to use NS* based integers so that Swift can easily bridge them. But otherwise, you can cast at the calling point:

delegate!.drawTopEdge(j, col: CInt(i))

See Dealing with C APIs and Foundation Data Types for more.