I am combining Swift and Objective-C in the same project. I am trying to use STTwitter cocoapod as follows:
- (void)getStatusesLookupTweetIDs:(NSArray *)tweetIDs
successBlock:(void (^)(NSArray *))successBlock
errorBlock:(void (^)(NSError *))errorBlock {
[self getStatusesLookupTweetIDs:tweetIDs
includeEntities:@(YES)
trimUser:@(YES)
map:@(YES)
successBlock:successBlock
errorBlock:errorBlock];
}
Swift code
twitterApi.getStatusesLookupTweetIDs(ids, successBlock: { (tweets: [AnyObject]!) -> Void in
process(tweets)
finish()
}, errorBlock: { (err) -> Void in
error(err)
})
Everything looks fine in Obj-C (I did not try to examine the variable passed in successBlock, they all have valid values). But in Swift, when successBlockexecuted, tweetswas:
Printing description of tweets:
([AnyObject]!) tweets = 1 value {
[0] = <error: use of undeclared identifier 'cocoarr'
error: 1 errors parsing expression
>
}
How do I fix this and pass NSArrayto Swift? (No compilation error)
source
share