Hi, I have a tabbed bar application. sometime when I click on tab Bar Item, if the internet speed is slow, then it takes time to show the tabBarItem which is clicked already for few seconds, I want to display activity indicator if it takes time to show the tabBarItem. other times when internet is in good speed and it is opening quickly then i dont need it in that case.
You have it set up wrong if switching to the tab takes a while. You should make it so that you can switch to the tab right away, and then if downloading needs to happen, it doesn't start until the view is shown. And if it could take a while, then the downloading should be done asynchronously.
You have it set up wrong if switching to the tab takes a while. You should make it so that you can switch to the tab right away, and then if downloading needs to happen, it doesn't start until the view is shown. And if it could take a while, then the downloading should be done asynchronously.
Hi, Thanks for response, Actually I am using JsonSearlization object on almost every tabBar Item, I get data from remote location in a Dicationary and load using ViewwillAppear of every tabBar Item..
The case i talked about, sometimes the data from the remote location can be huge and loading in Tables, on different tab bar items i am updating the data also and data is readily available after updating when i switch to see the data on other baritem. and when using no-WIFI or internet speed is low, then this is taking time... otherwise tabBar items are changing instantly.
Yes I read what you said... I know how to do asynchronous request but that is the case when you use NSURLConnection, I am using a NSJsonSearlized object and in that I dont know any asychronous or synchronous request... I see your sarcasm, but I read your post. I have actually tried to show activityindicator when current tabbar item willDisappear method and as well as the next tab bar item willappear method... but it does not work for me.
Well, you are doing that code in viewWillAppear, so it is always going to happen before you can switch to the tab. That's why you have to wait. If you change that to viewDidAppear, that alone will help.
I'm also reasonably certain that NSJSONSerialization has nothing to do with it. Where does your data come from?
Well, you are doing that code in viewWillAppear, so it is always going to happen before you can switch to the tab. That's why you have to wait. If you change that to viewDidAppear, that alone will help.
I'm also reasonably certain that NSJSONSerialization has nothing to do with it. Where does your data come from?
thanks, I will try this willdidAppear, my data comes from a remote php page.
I knew you were going to say something like that, and I knew it would be a useless answer.
The code. How are you getting the data in code?
It could be useless but I have tried it nothing has changed.
I get the data in a NSDictionay because I have data in a form of big dictionary, which includes single values and values as array also. so i just get the values for particular keys and if it is array then i just traverse the array using loop and it shows the data.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
It could be useless but I have tried it nothing has changed.
I'm also going to guess that you did it wrong. So rather than showing the same line of code over and over again, copy-paste the ENTIRE method. I swear I don't understand why new people think their code is top secret.
And now I have Implemented the functionality using asynchronous request... but it makes my app more miserable. using the above line of code which i wrote before... was must faster... than this.. now...
Code:
-(void)LoadDataFromURL:(NSString*)urlString{
NSString *requestUrl = [NSString stringWithFormat:urlString];
NSURLRequest *urlRequest = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:requestUrl]];
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
// Send an asyncronous request on the queue
[NSURLConnection
sendAsynchronousRequest:urlRequest queue:queue completionHandler:^(NSURLResponse *response,
NSData *data, NSError *error) {
// If there was an error getting the data
if (error) {
// show alert
}
NSError *jsonError;
NSDictionary *response = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&jsonError];
// If there was an error decoding the JSON
if (jsonError) {
// show alert
}
// load the data into the fields
[self updateDetailswithDictionary:response];
} ];
}
There is no reason for that to be any slower. You've done something wrong.
and what you see something wrong in this code ??? this is all the request... don't you think if something wrong should be happening... happening here.. only that the data from dictionary is loading on a table cells.... so I assign the values in the list and then add to the cells of tableview...
You need to start using specifics, because you don't explain yourself well at all. "More miserable" means what, exactly? It was taking 0.5 seconds to download before, and now it takes 10? What?
I'm still waiting for you to prove that you did the viewDidAppear part correctly.
Start providing useful information, or I'm going to get bored and leave this thread.
You need to start using specifics, because you don't explain yourself well at all. "More miserable" means what, exactly? It was taking 0.5 seconds to download before, and now it takes 10? What?
I'm still waiting for you to prove that you did the viewDidAppear part correctly.
Start providing useful information, or I'm going to get bored and leave this thread.
Yes, I understand your point, when i implemented without asynchronous request, using only jsonObject, it was loading when screen was loading. Now after asynchronous request I have to wait more than 5 seconds. I dont think it is a mystery to implement viewDidAppear method ??? I called the method which is sending the request in the viewDidAppear Method.. this is what i do...
I know it could be boring for you but I feel it is writing exactly how it should be and still not working... :O
You need to start using specifics, because you don't explain yourself well at all. "More miserable" means what, exactly? It was taking 0.5 seconds to download before, and now it takes 10? What?
I'm still waiting for you to prove that you did the viewDidAppear part correctly.
Start providing useful information, or I'm going to get bored and leave this thread.
I have one more method where i write the complete url and call the above asynchronous request method
here is how i do what i do...
Code:
-(void) update{
NSString *urlString=[NSString stringWithFormat:@"%@getData.php",self.appDelegate.url];
// calling the method which sends the asynchronous request
[self downloadDatafromURL:urlString];
}
-(void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self update];
}
Well, you didn't know to try viewDidAppear in the first place, so you don't have much experience.
You didn't know that this should be done with an asynchronous request, so you don't have much experience.
You keep pointing to your JSON parsing as proof that you can't do an asynchronous request, which means you don't really know what you are doing.
You provide very bad answers to questions, which demonstrates that you don't really understand what is being said.
Which part of this means that I should trust what you are doing at all? So when you come back and say "this change didn't matter" or "now it is worse", why should I believe that you did it correctly? You haven't demonstrated any skills yet. So in the absence of skill, you should post code. Not explanations, code.
Well, you didn't know to try viewDidAppear in the first place, so you don't have much experience.
You didn't know that this should be done with an asynchronous request, so you don't have much experience.
You keep pointing to your JSON parsing as proof that you can't do an asynchronous request, which means you don't really know what you are doing.
You provide very bad answers to questions, which demonstrates that you don't really understand what is being said.
Which part of this means that I should trust what you are doing at all? So when you come back and say "this change didn't matter" or "now it is worse", why should I believe that you did it correctly? You haven't demonstrated any skills yet. So in the absence of skill, you should post code. Not explanations, code.
Here i post the code again about viewDidAppear method, I have just posted above also..before you answered...
Code:
-(void) update{
NSString *urlString=[NSString stringWithFormat:@"%@getData.php",self.appDelegate.url];
// calling the method which sends the asynchronous request
[self downloadDatafromURL:urlString];
}
-(void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self update];
}
Well, you didn't know to try viewDidAppear in the first place, so you don't have much experience.
You didn't know that this should be done with an asynchronous request, so you don't have much experience.
You keep pointing to your JSON parsing as proof that you can't do an asynchronous request, which means you don't really know what you are doing.
You provide very bad answers to questions, which demonstrates that you don't really understand what is being said.
Which part of this means that I should trust what you are doing at all? So when you come back and say "this change didn't matter" or "now it is worse", why should I believe that you did it correctly? You haven't demonstrated any skills yet. So in the absence of skill, you should post code. Not explanations, code.
Yes you are right that I did not know in the start but I have implemented that and I showed the code also... If you can not see the code then i post here again and tell me where I am not doing the asynchronous request???? I would be beginner but don't tell me that I am stupid even I write the whole request and it is taking time to show the results...
Code:
-(void)LoadDataFromURL:(NSString*)urlString{
NSString *requestUrl = [NSString stringWithFormat:urlString];
NSURLRequest *urlRequest = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:requestUrl]];
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
// Send an asyncronous request on the queue
[NSURLConnection
sendAsynchronousRequest:urlRequest queue:queue completionHandler:^(NSURLResponse *response,
NSData *data, NSError *error) {
// If there was an error getting the data
if (error) {
// show alert
}
NSError *jsonError;
NSDictionary *response = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&jsonError];
// If there was an error decoding the JSON
if (jsonError) {
// show alert
}
// load the data into the fields
[self updateDetailswithDictionary:response];
} ];
NSString *urlString=[NSString stringWithFormat:@"%@getData.php",self.appDelegate.url];
// calling the method which sends the asynchronous request
[self downloadDatafromURL:urlString];
}
-(void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self update];
}