Memory Management in Swift

Posted Leave a commentPosted in Tutorials

Understanding Memory Management, Strong, Weak and Unowned References Behind all the coding that we are doing, you may have noticed some of your variables with the reference of strong, weak or unowned when writing your codes. What is Memory Management and what does the reference really means? The usage of strong, weak or unowned are actually related to the memory management in Swift called Automatic Reference Counting also referred to as (ARC). Let’s slow down a little and try to understand what this means. So, ARC actually does automatic reference counting. In the definition of Computer Science, Reference Counting is a technique of storing number of references, pointers, or handles into a resources such as an object, block or memory, disk space or other resources. In short, ARC actually helps store references into memory and helps clean up when it is not being used. On a side note, reference counting in this case only applies to instance of classes and not structures and enumerations as they are both value types […]

Backendless 4 friend function fix for QuickChat 2.0

Posted Leave a commentPosted in Tutorials

Since Backendless Version 4 is different then the Version 3, some of the students were having issues adding friends to the user. Here is a fix how to change the code to work with Backendless version 4. We have to change 4 files in the App. The change is only for load function, also we are adding 1 extra function to each file. you have to update 4 files to make it work, below is each file with its code updates, the rest of the functions stay as they are Friend.swift file import Foundation class Friend: NSObject { var objectId: String? var userOneId: String? // var userTwo: BackendlessUser? <—Old Code var userTwo: String? //<—–New Code } FriendsViewController.swift filr //Replace old load with this func loadFriends() { cleanup() let whereClause = “userOneId = ‘\(backendless!.userService.currentUser.objectId!)'” let queryBuilder = DataQueryBuilder() queryBuilder!.setWhereClause(whereClause) dataStore?.find(queryBuilder, response: { (friends_) -> () in if friends_ != nil { print(“have friends”) let friends = friends_! as! [Friend] self.friendObjects = friends for friend in friends { self.friendId.append(friend.userTwo as! String) } […]