Graphics Reference
In-Depth Information
dispatch_get_global_queue
(
DISPATCH_QUEUE_PRIORITY_HIGH
,
0
), ^{
//setup
NSString
*fileName =
self
.
items
[index];
NSString
*pngPath = [[
NSBundle
mainBundle
]
pathForResource
:filename
ofType
:
@"png"
inDirectory:ImageFolder];
NSString
*jpgPath = [[
NSBundle
mainBundle
]
pathForResource
:filename
ofType
:
@"jpg"
inDirectory:ImageFolder];
//load
NSInteger
pngTime = [
self
loadImageForOneSec
:pngPath] *
1000
;
NSInteger
jpgTime = [
self
loadImageForOneSec
:jpgPath] *
1000
;
//updated UI on main thread
dispatch_async
(
dispatch_get_main_queue
(), ^{
//find table cell and update
NSIndexPath
*indexPath =
[
NSIndexPath
indexPathForRow
:index
inSection
:
0
];
UITableViewCell
*cell =
[
self
.
tableView
cellForRowAtIndexPath
:indexPath];
cell.
detailTextLabel
.
text
=
[
NSString
stringWithFormat
:
@"PNG: %03ims JPG: %03ims"
,
pngTime, jpgTime];
});
});
}
- (
NSInteger
)tableView:(
UITableView
*)tableView
numberOfRowsInSection:(
NSInteger
)section
{
return
[
self
.
items
count
];
}
- (
UITableViewCell
*)tableView:(
UITableView
*)tableView
cellForRowAtIndexPath:(
NSIndexPath
*)indexPath
{
//dequeue cell
UITab
leViewCell
*cell =
[
self
.
tableView
dequeueReusableCellWithIdentifier
:
@"Cell"
];
if
(!cell)
{
cell = [[
UITableViewCell
alloc
]
initWithStyle
:
UITableViewCellStyleValue1
reuseIdentifier
:
@"Cell"
];
}