I am fetching from the fbgraph api and showing in a view.
the code for fetching is below.
func fetchProfile(){
let parameters = ["fields":"email, name, picture.type(large)"]
FBSDKGraphRequest(graphPath: "me", parameters: parameters).startWithCompletionHandler { (connection, result, error) in
if error != nil{
print(error)
return
} else {
print(result)
self.nameLabel.text = result["name"] as? NSString as? String
self.emailAddress.text = result["email"] as? NSString as? String
if let picture = result["picture"] as? NSDictionary, data = picture["data"] as? NSDictionary, url = data["url"] as? String{
print("this is what yout fetch with \(url)")
self.imageView.sd_setImageWithURL(NSURL(string: url))
}
}
}
}
The Code in viewDidLoad
override func viewDidLoad() {
super.viewDidLoad()
self.imageView.clipsToBounds = true
self.imageView.layer.masksToBounds = true
self.imageView.layer.cornerRadius = self.imageView.frame.height/2
self.fetchProfile()
}
Whenever the application runs and it starts to show it takes around 1.5 seconds to show all of it. is thier any way you can cache this data so whenever the screen comes up you dont have to wait 2.0 seconds as it automatically shows up as the view shows up as its caches. as it is the fist view to show up