adamwulf/JotUI

+[UIImage circleBrushTexture]: unrecognized selector sent to class 0x106d7aa50 using Swift?

Opened this issue · 3 comments

Sorry for buggin'!

I'm having trouble, perhaps it's on my part, but i get the unrecognized selector error. I'm using Swift to implement JotUI and the following function is the culprit:

  • (JotSharedBrushTexture*)brushTexture {
    JotGLContext* currContext = (JotGLContext*)[JotGLContext currentContext];
    (... yada yada yada ....)
    JotSharedBrushTexture* texture = [currContext.contextProperties objectForKey:@"brushTexture"];
    if (!texture) {
    // ######## PROBLEM ########
    NSLog(@"Creating a texture");
    texture = [[JotSharedBrushTexture alloc] initWithImage:[UIImage circleBrushTexture]];
    NSLog(@"After creating texture"); // doesn't log from here.
    // ########################
    [currContext.contextProperties setObject:texture forKey:@"brushTexture"];
    }
    return texture;
    }

Could this be because I'm just using Swift and this on my part?

[UIImage circleBrushTexture] is defined in UIImage+BrushTextures.h/m. I suspect you just need to translate those files to Swift as well, and then it'll work fine :)

Very interested to hear how the Swift port goes! Keep me updated for sure, that'll be awesome when it's done

Oh ha! I probably misread your comment that you were translating into swift, not importing into your swift project! My only excuse is that it's very late at night and shouldn't be replying to things... :)

Another thought- look at the other linker flags in build settings and make sure they have the -ObjC -all_load. Check the included sample project- I may need to update the readme about that.

Ok - I double checked and i'd missed adding that to the readme, so just pushed an update for that - thanks for posting about the issue :). It also seems that only -ObjC is needed, not the -all_load, at least for the included sample project, so give that a try first.