Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Dec 18, 2012, 01:01 PM   #1
waterskier2007
macrumors 68000
 
waterskier2007's Avatar
 
Join Date: Jun 2007
Location: White Lake, MI
Send a message via AIM to waterskier2007
Problem updating UIProgressView during progress

Hey guys,

I am having a problem updating the UIProgressView while I perform some tasks involving HTTP requests. I cant run the other stuff on the background because the app crashes with an error about not running UIKit stuff in the background thread.

Basically I am doing a bunch of HTTP gets and posts and I want to update my progress bar as i accomplish each set of gets/posts.

I have tried calling [self performSelectorOnMainThread]
and passing a method that updates my progress view but it doesn't work. Can anyone provide me with some help. Just ask me for more info on what you need and I will supply it. Thanks so much
__________________
2012 Mac Mini, 2.6 GHz, 16GB RAM, 1TB HDD
2.4Ghz 15" Macbook Pro
16 GB iPhone 5 : 32 GB iPhone 4S : 16 GB iPad 3
16 GB Nexus 7 (2012)
waterskier2007 is offline   0 Reply With Quote
Old Dec 18, 2012, 01:03 PM   #2
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Are your HTTP tasks already running on the main thread? If not, how are you splitting them off?
__________________
dejo is offline   0 Reply With Quote
Old Dec 18, 2012, 01:27 PM   #3
waterskier2007
Thread Starter
macrumors 68000
 
waterskier2007's Avatar
 
Join Date: Jun 2007
Location: White Lake, MI
Send a message via AIM to waterskier2007
Quote:
Originally Posted by dejo View Post
Are your HTTP tasks already running on the main thread? If not, how are you splitting them off?
I am using ASIHTTPRequests and they are all synchronous, on the main thread (I don't specify anything different). I am not very familiar with backgrounding (besides what I have tried to do today), so forgive me if I am not providing the right information
__________________
2012 Mac Mini, 2.6 GHz, 16GB RAM, 1TB HDD
2.4Ghz 15" Macbook Pro
16 GB iPhone 5 : 32 GB iPhone 4S : 16 GB iPad 3
16 GB Nexus 7 (2012)
waterskier2007 is offline   0 Reply With Quote
Old Dec 18, 2012, 01:31 PM   #4
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Try taking advantage of ASIHTTPRequest asynchronous abilities.

http://allseeing-i.com/ASIHTTPRequest/How-to-use
__________________
dejo is offline   0 Reply With Quote
Old Dec 18, 2012, 01:34 PM   #5
waterskier2007
Thread Starter
macrumors 68000
 
waterskier2007's Avatar
 
Join Date: Jun 2007
Location: White Lake, MI
Send a message via AIM to waterskier2007
Quote:
Originally Posted by dejo View Post
Try taking advantage of ASIHTTPRequest asynchronous abilities.

http://allseeing-i.com/ASIHTTPRequest/How-to-use
I actually tried doing that in an old project of mine. The problem that I ran into is that I put all of my HTTP related methods in another class and use class methods to run them. For this reason I would have to write a ton more code and use instance methods so that my original view would get the delegate/protocol calls when the requests finished. Is that true?
__________________
2012 Mac Mini, 2.6 GHz, 16GB RAM, 1TB HDD
2.4Ghz 15" Macbook Pro
16 GB iPhone 5 : 32 GB iPhone 4S : 16 GB iPad 3
16 GB Nexus 7 (2012)
waterskier2007 is offline   0 Reply With Quote
Old Dec 18, 2012, 01:45 PM   #6
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by waterskier2007 View Post
I actually tried doing that in an old project of mine. The problem that I ran into is that I put all of my HTTP related methods in another class and use class methods to run them.
Is that the case with your current project as well? If not, don't worry about it, unless you feel it makes more sense to separate the HTTP handling.

Quote:
Originally Posted by waterskier2007 View Post
For this reason I would have to write a ton more code and use instance methods so that my original view would get the delegate/protocol calls when the requests finished. Is that true?
If you can take advantage of using blocks, that might help.

I can't really give you a concrete answer without knowing much more about how your code is structured and being executed (including seeing some actual code).
__________________
dejo is offline   0 Reply With Quote
Old Dec 18, 2012, 01:50 PM   #7
waterskier2007
Thread Starter
macrumors 68000
 
waterskier2007's Avatar
 
Join Date: Jun 2007
Location: White Lake, MI
Send a message via AIM to waterskier2007
Quote:
Originally Posted by dejo View Post
Is that the case with your current project as well? If not, don't worry about it, unless you feel it makes more sense to separate the HTTP handling.
Yes it helps me have the code that way because it is less clutter in my view controller class. It makes more sense to me that way.

Quote:
Originally Posted by dejo View Post
If you can take advantage of using blocks, that might help.
I just started watching the Paul Hegarty lectures on blocks, so maybe after I finish that I could implement them

Quote:
Originally Posted by dejo View Post
I can't really give you a concrete answer without knowing much more about how your code is structured and being executed (including seeing some actual code).
Can't share the code, as it is for work (not my primary task, just a fun side thing with some coworkers. If I really needed to implement the progress bar I would continue to try and figure it out but I will leave it for a later time as it is not critical. Thanks for your help, you seem to be present in every useful thread I visit here
__________________
2012 Mac Mini, 2.6 GHz, 16GB RAM, 1TB HDD
2.4Ghz 15" Macbook Pro
16 GB iPhone 5 : 32 GB iPhone 4S : 16 GB iPad 3
16 GB Nexus 7 (2012)
waterskier2007 is offline   0 Reply With Quote
Old Dec 18, 2012, 04:48 PM   #8
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by waterskier2007 View Post
Thanks for your help, you seem to be present in every useful thread I visit here
And even some of the useless ones!

Thanks for the compliment, though.
__________________
dejo is offline   0 Reply With Quote
Old Dec 18, 2012, 05:46 PM   #9
PhoneyDeveloper
macrumors 68030
 
PhoneyDeveloper's Avatar
 
Join Date: Sep 2008
You should always use asynchronous downloads with ASI or other URL downloading classes. For ASI you need basically three callbacks: one for success, one for failure, one for progress. You start the async download on the main thread and it calls you back on the main thread. All the background code is transparent to your code.

BTW, ASI is now defunct so it would be better to use another class for this, like AFNetworking.
PhoneyDeveloper is offline   0 Reply With Quote
Old Dec 19, 2012, 01:15 AM   #10
jnoxx
macrumors 65816
 
jnoxx's Avatar
 
Join Date: Dec 2010
Location: Aartselaar // Antwerp // Belgium
Or you could use the NSUrlConnection which since iOS 5 has an Async version to.. It uses blocks so it's quite easy to implement
__________________

iPad Mini, iPad 4, iPad 2, iPhone 3G,4,5, iMac 24", Mac Mini Last gen, Macbook Pro Retina with Dell U2711
jnoxx is offline   0 Reply With Quote
Old Dec 21, 2012, 12:38 PM   #11
waterskier2007
Thread Starter
macrumors 68000
 
waterskier2007's Avatar
 
Join Date: Jun 2007
Location: White Lake, MI
Send a message via AIM to waterskier2007
Quote:
Originally Posted by PhoneyDeveloper View Post
You should always use asynchronous downloads with ASI or other URL downloading classes. For ASI you need basically three callbacks: one for success, one for failure, one for progress. You start the async download on the main thread and it calls you back on the main thread. All the background code is transparent to your code.

BTW, ASI is now defunct so it would be better to use another class for this, like AFNetworking.
I did end up changing some of my larger requests to Asynchronous. Also, what do you mean it is defunct? If it still works, I don't see the problem with using it. Maybe you could elaborate on that. Thanks
__________________
2012 Mac Mini, 2.6 GHz, 16GB RAM, 1TB HDD
2.4Ghz 15" Macbook Pro
16 GB iPhone 5 : 32 GB iPhone 4S : 16 GB iPad 3
16 GB Nexus 7 (2012)
waterskier2007 is offline   0 Reply With Quote
Old Dec 22, 2012, 12:00 AM   #12
PhoneyDeveloper
macrumors 68030
 
PhoneyDeveloper's Avatar
 
Join Date: Sep 2008
Note the date

http://allseeing-i.com/%5Brequest_release%5D;
PhoneyDeveloper is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Reading List icon is forever stuck on updating (a little bit of blue progress) patent10021 Mac Basics and Help 0 Oct 24, 2013 12:55 PM
iPhone: updating problem amir16david iOS 6 2 Sep 25, 2013 04:10 PM
Problem updating from 10.5.8 Jhead476 OS X 10 Apr 22, 2013 11:01 PM
iPad: Problem updating ios Fipad iOS 6 2 Sep 21, 2012 09:04 PM
Problem after updating free2australian iMac 7 Jul 31, 2012 04:39 PM

Forum Jump

All times are GMT -5. The time now is 12:46 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC