I’m making the app-book for ipad like app-magazine.
Now I’m using ScrollView and want to load many 1024*768 images(about 100 images), (As you know, If all images are loaded at once, It is impossible.)
so I load just 5 pages(current page & 2 pre pages & 2 next pages) and remove the other pages.
But, I have a question.
I made the method(‘loadTitlePage’) for loading the page and I have to call this method when I want to load all pages.
So, I can’t use dispatch_async but dispatch_sync.
Is there any difference between using dispatch_sync and writing code in line(non-block without dispatch_sync)?
It’s my code.
[self loadTitlePage:currentPageNo];
dispatch_queue_t dqueue = dispatch_queue_create("scrollLoadTitlePage", NULL);
dispatch_sync(dqueue, ^{
[self loadTitlePage:currentPageNo-2]; });
dispatch_sync(dqueue, ^{
[self loadTitlePage:currentPageNo-1]; });
dispatch_sync(dqueue, ^{
[self loadTitlePage:currentPageNo+1]; });
dispatch_sync(dqueue, ^{
[self loadTitlePage:currentPageNo+2]; });
dispatch_sync(dqueue, ^{
[self removeTitlePage:currentPageNo-3 withNo:currentPageNo+3]; });
You can read here: using dispatch_sync in Grand Central Dispatch
In short.. dispatch_sync is equivalent to a mutex lock.. in your case I don’t think there is any difference