1

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]; });
bdash
  • 18,110
  • 1
  • 59
  • 91
ssongahlee
  • 91
  • 1
  • 10

1 Answers1

1

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

Community
  • 1
  • 1
Francesco
  • 1,840
  • 19
  • 24
  • thanks a lot. I' had seen that link page before. But I'm beginner in programming, so a little bit I confused. Thank you for your answer :) – ssongahlee Mar 22 '12 at 12:50