how to implement lazy loading of images in table view using swift

Old Solution: Since you doesn’t show any code. Here is the example for you. func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { // try to reuse cell let cell:CustomCell = tableView.dequeueReusableCellWithIdentifier(“DealCell”) as CustomCell // get the deal image let currentImage = deals[indexPath.row].imageID let unwrappedImage = currentImage var image = self.imageCache[unwrappedImage] let imageUrl = NSURL(string: … Read more

Which has faster performance indexesOfObjectsPassingTest or filteredArrayUsingPredicate?

The following tests (compiled in Release mode, executed on a Mac Pro) indicate that filteredArrayUsingPredicate is slower than indexesOfObjectsPassingTest if you use a “textual” predicate, but faster if you use block-based predicate. The fasted method in my test was a simple (fast-enumeration) loop that adds all matching objects to a mutable array. Results for filtering … Read more

[NSObject : AnyObject]?’ does not have a member named ‘subscript’ error in Xcode 6 beta 6

As mentioned in the Xcode 6 beta 6 release notes, a large number of Foundation APIs have been audited for optional conformance. These changes replace T! with either T? or T depending on whether the value can be null (or not) respectively. notification.userInfo is now an optional dictionary: class NSNotification : NSObject, NSCopying, NSCoding { … Read more

EXC_BAD_ACCESS when building nspredicate

The issue is the placeholder, not with NSPredicate directly, but with initWithFormat: that is innerly called. %@ shouldn’t be used with an int, use %d instead. So this line: NSPredicate *pred = [NSPredicate predicateWithFormat:@”(alter_min_monat > %@)”, months]; Should be: NSPredicate *pred = [NSPredicate predicateWithFormat:@”(alter_min_monat > %d)”, months]; Other linked information : String Programming Guide: String … Read more

SwiftUI List color background

iOS 16 Since Xcode 14 beta 3, You can change the background of all lists and scrollable contents using this modifier: .scrollContentBackground(.hidden) You can pass in .hidden to make it transparent. So you can see the color or image underneath. iOS 15 and below All SwiftUI’s Lists are backed by a UITableView (until iOS 16). … Read more