cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shortstuffsushi <>
Subject [GitHub] cordova-plugin-file-transfer pull request: Fixed - Xcode erros. CD...
Date Fri, 21 Mar 2014 13:51:05 GMT
Github user shortstuffsushi commented on the pull request:
    I don't know that I'd say the existing code is bad, or even wrong. Ternary and coalescing
operators are commonly used in Objective-C. There aren't really any standards around the various
Cordova repositories, so I don't think it's an issue. In fact, your pull request here is using
a variable that doesn't exist, which wouldn't fix the problem either :(
    The ultimate problem is that `[NSURL URLWithString:source]` returns an `id` which Xcode
is incorrectly attempting to cast to a `CGPathContext`, if I remember correctly. That class
does not have a `path` selector, and consequently Xcode incorrectly assumes the line is invalid.
    To fix this, you can use any of these chunks of code, depending on your preference. They'll
all work.
    NSString *filePath = [source hasPrefix:@"/"] ? [source copy] : [(NSURL *)[NSURL URLWithString:source]
    NSString *filePath = [source hasPrefix:@"/"] ? [source copy] : [[NSURL alloc] initWithString:source]
    NSString *filePath;
    if ([source hasPrefix:@"/"]) {
        filePath = [source copy];
    else {
        filePath = [(NSURL *)[NSURL URLWithString:source] path];
        // or
        filePath = [[NSURL alloc] initWithString:source] path];
    NSURL *url = [NSURL URLWithString:source]; // or [[NSURL alloc] initWithString:source];
    NSString *filePath = [url path];
    @agrieve, could you choose one and pull it in to close this issue out, please?

If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at or file a JIRA ticket
with INFRA.

View raw message