Ответ на вызов из objective- c с для каждого на swift class , путем изменения массива в NSArray и реализовать NSFastEnumeration.
@objcMembers public class FeedItemsCollection:NSObject,NSFastEnumeration,Sequence
{
//private var feedItems:[FeedItem]
private var feedItems:NSMutableArray
public init(feedItems :NSMutableArray)
{
self.feedItems = feedItems
}
public func makeIterator() ->NSFastEnumerationIterator
{
return NSFastEnumerationIterator(self)
}
public func countByEnumerating(with state: UnsafeMutablePointer<NSFastEnumerationState>, objects buffer: AutoreleasingUnsafeMutablePointer<AnyObject?>, count len: Int) -> Int {
return self.feedItems.countByEnumerating(with: state, objects: buffer, count: len);
}
}
и код target- c, который вызывает для каждого l oop
self.feedItemsCollection = [[FeedItemsCollection alloc] initWithFeedItems:entities];
for(FeedItem * feedItem in self.feedItemsCollection)
{
NSLog(@"feedItem-title = %@", feedItem.title);
}