Вопрос по objective-c, ios – NSURLConnection делегат

0

REVISED ...

Error: User Rate Limit Exceeded

Вот некоторый код из моего AppDelegate:

StartViewController *svc = [[StartViewController alloc] init];
TradeViewController *tvc = [[TradeViewController alloc] init];
CashViewController *cvc = [[CashViewController alloc] init];
ComViewController *covc = [[ComViewController alloc] init];
PrefsViewController *pvc = [[PrefsViewController alloc] init];

NSMutableArray *tabBarViewControllers = [[NSMutableArray alloc] initWithCapacity:5];
UITabBarController *tabBarController = [[UITabBarController alloc] init];

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:svc];
[tabBarViewControllers addObject:navigationController];
navigationController = nil;

navigationController = [[UINavigationController alloc] initWithRootViewController:tvc];
[tabBarViewControllers addObject:navigationController];
navigationController = nil;

navigationController = [[UINavigationController alloc] initWithRootViewController:cvc];
[tabBarViewControllers addObject:navigationController];
navigationController = nil;

navigationController = [[UINavigationController alloc] initWithRootViewController:covc];
[tabBarViewControllers addObject:navigationController];
navigationController = nil;

navigationController = [[UINavigationController alloc] initWithRootViewController:pvc];
[tabBarViewControllers addObject:navigationController];
navigationController = nil;

[tabBarController setViewControllers:tabBarViewControllers];

[[self window] setRootViewController:tabBarController];

self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

  1. The singleton class NSURLConnection is handling ALL of my communication. Everything from a simple, email change all the way to updating transaction tables. This just seems wrong to me and makes it very difficult to keep track on who is calling what. Again, I am going by my interpretation of MVC. I think it would be much easier to have a NSURLConnection for every VC and do some processing in those classes. However that would not be MVC(ish).

  2. I have close to a 100 variables, arrays, etc… in my singleton class which I use to assign values to all my VC. This also seems wrong to me but I can't think of any other way.

Error: User Rate Limit Exceeded sangony
Error: User Rate Limit Exceeded Jitendra Singh

Ваш Ответ

5   ответов
3

how can I distinguish in the NSURLConnection delegate (connectionDidFinishLoading) which URL call is being made?

Error: User Rate Limit Exceeded-connectionDidFinishLoading:Error: User Rate Limit ExceededconnectionError: User Rate Limit Exceeded

How can I tell outside of "connectionDidFinishLoading" when the download is completed?

Error: User Rate Limit ExceededtellsError: User Rate Limit Exceeded

Update:Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

  • break your problem into parts that are easier to solve

  • limit the scope of each class's responsibilities

  • if something seems to complicated, it probably is

Error: User Rate Limit Exceeded

Error: User Rate Limit ExceededreallyError: User Rate Limit Exceeded
Error: User Rate Limit ExceededdidFinishError: User Rate Limit ExceededdidFinishError: User Rate Limit Exceeded
Error: User Rate Limit Exceeded sangony
Я разместил больше фона. Надеюсь, это не излишне :) sangony
1

Error: User Rate Limit ExceededtagError: User Rate Limit ExceededisFinishedError: User Rate Limit Exceeded#defineError: User Rate Limit ExceededconnectionDidFinishLoadingError: User Rate Limit ExceededisFinishedError: User Rate Limit Exceeded


Error: User Rate Limit Exceeded

TTURLConnection.h:

#import <Foundation/Foundation.h>

@interface TTURLConnection : NSURLConnection <NSURLConnectionDelegate>

@property (nonatomic) NSInteger tag;
@property (nonatomic) BOOL isLocked;

- (id)initWithRequest:(NSURLRequest *)request delegate:(id)delegate startImmediately:
    (BOOL)startImmediately tag:(NSInteger)tagParam;

@end

TTURLConnection.m:

#import "TTURLConnection.h"

@implementation TTURLConnection

@synthesize tag;

- (id)initWithRequest:(NSURLRequest *)request delegate:(id)delegate startImmediately:
    (BOOL)startImmediately tag:(NSInteger)tagParam {
    self = [super initWithRequest:request delegate:delegate 
        startImmediately:startImmediately];

    if(self) {
        self.tag = tagParam;
    }

    return self;
}

@end
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded sangony
Error: User Rate Limit Exceeded sangony
1

Error: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit Exceeded

Error: User Rate Limit ExceededASIHttpRequestError: User Rate Limit ExceededdidFinishSelectorError: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

NSURL *url = [NSURL URLWithString:@"http://allseeing-i.com"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];

[request setDelegate:self];
[request startAsynchronous];
[request setDidFinishSelector:@selector(requestDone:)];

Error: User Rate Limit Exceeded

- (void)requestDone:(ASIHTTPRequest *)request
{
   // Use when fetching text data
   NSString *responseString = [request responseString];

   // Use when fetching binary data
   NSData *responseData = [request responseData];

   // If you want, you can get the url of the request like this
   NSURL *url = [request url];
}

Error: User Rate Limit ExceededrequestDone:Error: User Rate Limit Exceeded

Error: User Rate Limit ExceededASIHttpRequestError: User Rate Limit ExceededError: User Rate Limit Exceeded.

Error: User Rate Limit Exceeded
NSURLConnectionError: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded sangony
1

Error: User Rate Limit Exceeded

[NSString stringWithFormat:@"%p", connection]

Error: User Rate Limit Exceeded

Error: User Rate Limit ExceededconnectionDidFinishLoading:Error: User Rate Limit Exceededconnection:didFailLoadWithError:Error: User Rate Limit Exceeded

1

Error: User Rate Limit Exceeded

- (void)connectionDidFinishLoading:(NSURLConnection*)connection
{   
    NSString *urlString = [[[connection originalRequest] URL] absoluteString];
    if ([urlString caseInsensitiveCompare:@"http://www.apple.com"] == NSOrderedSame) {
        //Do Task#1
    }
    else if ([urlString caseInsensitiveCompare:@"http://www.google.com"] == NSOrderedSame)
    {
        //Do Task#2
    }
}
Error: User Rate Limit Exceeded sangony
Error: User Rate Limit Exceeded

Похожие вопросы