Search code examples
iphoneiosxcodesharekit

ShareKit Api Change


I am trying to change ShareKit API code of attachment to this code below:

dialog.attachment = [NSString stringWithFormat:@"{\"name\":\"%@\",\"href\"
:\"%@\",\"media\":[{\"type\":\"image\",\"src\":\"http://example.com/example.png\"
,\"href\": \"http://example.com/\"}]} ",item.title == nil ? SHKEncodeURL(item.URL) 
SHKEncode(item.title),SHKEncodeURL(item.URL)];

Xcode Keeps telling me prefix error. What am I missing?


Solution

  • You are missing an colon in the three-way conditional;

    The original code looks like this:

    dialog.attachment = [NSString stringWithFormat:@"{\"name\":\"%@\",\"href\"
    :\"%@\",\"media\":[{\"type\":\"image\",\"src\":\"http://example.com/example.png\"
    ,\"href\": \"http://example.com/\"}]} ",item.title == nil ? SHKEncodeURL(item.URL) 
    SHKEncode(item.title),SHKEncodeURL(item.URL)];
    

    Change it to this

    dialog.attachment = [NSString stringWithFormat:@"{\"name\":\"%@\",\"href\"
    :\"%@\",\"media\":[{\"type\":\"image\",\"src\":\"http://example.com/example.png\"
    ,\"href\": \"http://example.com/\"}]} ",item.title == nil ? SHKEncodeURL(item.URL): 
    SHKEncode(item.title),SHKEncodeURL(item.URL)];
    

    The error is at the end of the third line.

    You should have seen this in the XCode editor, with a little yellow charat under the position where the error is.