I'm combining Swift and Objective-C in the same project. I am trying to use STTwitter cocoapod like this:
// objective-c
// STTwitter category method
//
- (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
// swift
twitterApi.getStatusesLookupTweetIDs(ids, successBlock: { (tweets: [AnyObject]!) -> Void in
process(tweets)
finish()
}, errorBlock: { (err) -> Void in
error(err)
})
Everything looks fine in Obj-C (I tried not investigate variable passed to successBlock
, they all have valid values). But in Swift, when successBlock
gets executed, tweets
was:
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 NSArray
into Swift? (No compile error)