开发者

Does checks the internet connection in the apps, affects the application performance in iPhone?

I want to check the net connection in my application. In my application i have eight buttons in the directory page. When i click the button, i have to check the net connection, if the net connection is available, then have to parsed the data and displayed in the table view. In my application, mostly i have done parsing and loads the web url's in the web view and used web services. Now i have completed my application, but overall application performance is little bit slow, So what i am thinking, i have checked each and every url functions be for the internet connections. I have also used reachability(from Apple Docs) code. So which code will be used in my applications for improving the performance of the apps.

Note:

In my client feed back, when compared to the performance of the application while runs in the WIFI, it much faster and runs in the 3G(Mobile Services) the performance will be little slow. So how can i improve my application performance, while checking the internet connection? Does any need to check the application runs in the WIFI or 3G?

I had used this code for checking the net connection in my apps,

NSStringEncoding enc;

NSError *error;

NSString *connected = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://www.apple.com"] usedEncoding:&enc error:&error];

if (connected == nil) {

        NSString * infoString = [NSString stringWithFormat:@"Please check your connection开发者_运维知识库 and try again."];

        UIAlertView * infoAlert = [[UIAlertView alloc] initWithTitle:@"Network Connection Error" message:infoString delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];

        [infoAlert show];

        [infoAlert release];


    } else {

        [self details:castString]; // Parsing method calls
  } 

So how can i improve the application performance, while checks the internet connection? and does affects the application performance?


So, naturally internet connection checking (assuming you're correctly doing it) will typically take longer on 3G than WiFi. This isn't that newsworthy. So if your issue is:

"it takes longer to check for connectivity, download, and parse on 3G"

...well, there are no surprises there.

To be honest, if you're using Apple's reachability code 'out of the box' there could be a lot of things going on here. How are you making the reachability call? Because Apple's sample does everything synchronously, so if you're calling it on the main thread there's your problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜