You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 25, 2019. It is now read-only.
import UIKit
import Spine
class ViewController: UIViewController {
var spine: Spine!
override func viewDidLoad() {
super.viewDidLoad()
setupSpine()
getPosts()
}
func setupSpine() {
spine = Spine(baseURL: URL(string: "http://test.com?access_token=test&page=1&per_page=15")!)
spine.registerResource(Post.self)
spine.registerResource(User.self)
}
func getPosts() {
spine.findAll(Post.self).onSuccess { posts, meta, _ in
for (_, postsResource) in posts.enumerated() {
let post = postsResource as! Post
print(post.user?.firstName ?? "", post.user?.lastName ?? "")
}
}.onFailure { error in
print("Fetching failed: \(error)")
}
}
}
First Posts model:
import UIKit
import Spine
// Resource class
class Post: Resource {
var user: User?
var message: String?
var dateAdd: String?
var dateUpdate: String?
override class var resourceType: ResourceType {
return "posts"
}
override class var fields: [Field] {
return fieldsFromDictionary([
"user": ToOneRelationship(User.self),
"message": Attribute(),
"dateAdd": Attribute().serializeAs("date-add"),
"dateUpdate": Attribute().serializeAs("date_update")
])
}
}
Second Users model:
import UIKit
import Spine
class User: Resource {
/// The ID of this resource.
var email: String?
var firstName: String?
var lastName: String?
var gender: NSNumber?
var phone: String?
var additionalPhone: String?
var skype: String?
var lastLogin: NSDate?
var bday: NSDate?
var role: String?
var img: String?
var isActive: NSNumber?
override class var resourceType: ResourceType {
return "users"
}
override class var fields: [Field] {
return fieldsFromDictionary([
"email": Attribute(),
"firstName": Attribute().serializeAs("first-name"),
"lastName": Attribute().serializeAs("last-name"),
"gender": Attribute(),
"phone": Attribute(),
"additionalPhone": Attribute().serializeAs("additional-phone"),
"skype": Attribute(),
"lastLogin": Attribute().serializeAs("last-login"),
"bday": DateAttribute(),
"role": Attribute(),
"img": Attribute(),
"isActive": Attribute().serializeAs("is-active")
])
}
}
further check it with Leak XCode instrument and got a lot of leaks (~60):
Do you have any suggestions how to fix it? Thanks
The text was updated successfully, but these errors were encountered:
Thanks for reporting this @ameli90! These definitely need to be fixed. Unfortunately I don't have much time to work on Spine now (hence also this late response). I'll see what I can do, but feel free to submit a PR if you have time to work on it :).
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I have created a simple example using Spine:
Do you have any suggestions how to fix it? Thanks
The text was updated successfully, but these errors were encountered: