Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

MACloop

macrumors 6502
Original poster
May 18, 2009
393
0
Germany
Hello,
I have an app using NSUrlConnection to connect to the internet and to get some data (XML). When the connection is done I parse the data. In the method parserDidEndDocument I fill a mapView with the data. It works fine. The problem is only that I want to block a segmentedController util the map has its annotations in place. I have set sementedControl.enable = YES at the end of the parser delegate method and have realized this is to sone. The annotations are put on the map (grapically) a bit later. So my question is - where am I after the parser is done? Can I call some delegate method for the view, the map...in order to keep my segmentedControl blocked till the map really is done??

Any ideas?
MACloop
 
Annoyingly there does not seem to be anything directly useful. I can only suggest that you schedule a method to run a short time later (say after 0.1 seconds) and use the viewForAnnotation: to check if the annotations have views: if they do they should be on screen...
 
Annoyingly there does not seem to be anything directly useful. I can only suggest that you schedule a method to run a short time later (say after 0.1 seconds) and use the viewForAnnotation: to check if the annotations have views: if they do they should be on screen...

Thants a good idea! Thanks alot - I will try that out!
/MACloop
 
How do I use a timer in this case? I suppse I should use NSTimer but have not used it before. Do you have a pseudo-code?
Thanks in advance!
MACloop
 
How do I use a timer in this case? I suppse I should use NSTimer but have not used it before. Do you have a pseudo-code?
Thanks in advance!
MACloop

If you want to use NSTimer then read the documentation. I don't see how pseudo code will help but here you go:

Code:
Add annotations
Schedule method to run after a short period called checkVisible

checkVisbile:
Set allVisible to true
For each annotation
  If the annotation does not have a view set allVisible to false
End for
if allVisible is true
  Show the control
else
  Schedule method to run after a short period called checkVisible
end if

I suspect what you really want me to post is sample code. I don't post that as I believe it encourages bad habits: not using the documentation, not trying to write your own code first, believing that copy/pasting code is programming and, in general, reducing learning and self reliance.

I would offer the suggestion that performSelector:withObject:afterDelay: would be better and easier to use than NSTimer.
 
If you want to use NSTimer then read the documentation. I don't see how pseudo code will help but here you go:

Code:
Add annotations
Schedule method to run after a short period called checkVisible

checkVisbile:
Set allVisible to true
For each annotation
  If the annotation does not have a view set allVisible to false
End for
if allVisible is true
  Show the control
else
  Schedule method to run after a short period called checkVisible
end if

I suspect what you really want me to post is sample code. I don't post that as I believe it encourages bad habits: not using the documentation, not trying to write your own code first, believing that copy/pasting code is programming and, in general, reducing learning and self reliance.

I would offer the suggestion that performSelector:withObject:afterDelay: would be better and easier to use than NSTimer.

Thanks alot and sorry for my bad english. Well, I did not want you to write my code, but give me advice about how to use the timer. I thought a pseudocode would give me a hint of the structure/flow. I will try your advice, instead of the timer. the timer does not seem to work so far. Perhaps have I missed something in the documantation. Again - thanks for your good advice!
MACloop
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.