Skip to content
Snippets Groups Projects
Commit 805857ff authored by cramakri's avatar cramakri
Browse files

Switch to asynchronous loading of images

SVN: 27172
parent 5cd310de
No related branches found
No related tags found
No related merge requests found
......@@ -69,11 +69,11 @@
// The detail item is now up-to-date. Update the user interface.
if (!self.detailItem) return;
self.summaryHeaderLabel.text = [self.detailItem.summaryHeader description];
self.summaryLabel.text = [self.detailItem.summary description];
self.identifierLabel.text = [self.detailItem.identifier description];
self.summaryHeaderLabel.text = self.detailItem.summaryHeader;
self.summaryLabel.text = self.detailItem.summary;
self.identifierLabel.text = self.detailItem.identifier;
if (self.detailItem.image) {
if (self.imageView.image != self.detailItem.image) {
self.imageView.image = self.detailItem.image;
}
......
......@@ -91,12 +91,15 @@
#pragma mark - Server Communication
- (void)syncSelectedObjectOnSuccess:(SuccessBlock)success
{
// Update the image
if (_selectedObject.imageUrl) {
NSURL *imageUrl = [NSURL URLWithString: _selectedObject.imageUrl];
NSData *imageData = [NSData dataWithContentsOfURL: imageUrl];
_selectedObject.image = [UIImage imageWithData: imageData];
success(_selectedObject);
// Load the image if necessary
if (_selectedObject.imageUrl && !_selectedObject.image) {
NSBlockOperation *blockOp = [NSBlockOperation blockOperationWithBlock: ^{
NSURL *imageUrl = [NSURL URLWithString: _selectedObject.imageUrl];
NSData *imageData = [NSData dataWithContentsOfURL: imageUrl];
_selectedObject.image = [UIImage imageWithData: imageData];
success(_selectedObject);
}];
[blockOp start];
} else {
success(_selectedObject);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment