Hi im getting this error,UIApplication may not respond to '+mainWindow' with my action sheet , but im not really sure why. any help would be greatly appreciated.
Code:
#import "cookieTestAppDelegate.h"
@implementation cookieTestAppDelegate
@synthesize window;
#pragma mark -
#pragma mark Application lifecycle
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
//NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
//NSString *MessageString = [ud stringForKey:"PSTextFieldSpecifier"];
//construct the web service url
//sets from the setting entry
NSString *startURL = (@"http://myiplinkhere/?func=******");
NSURL *url = [NSURL URLWithString:startURL];
//create a request object with that url
NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30];
//clear out the exisiting connection if there is on
if (connectionInProgress) {
[connectionInProgress cancel];
[connectionInProgress release];
}
//Instantiate the object to hold all incoming data
[cookieData release];
cookieData = [[NSMutableData alloc]init];
//create and initiate the connection - non-blocking
connectionInProgress = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES];
[self.window makeKeyAndVisible];
return YES;
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
[cookieData appendData:data];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
//we are just checking to make sure we are getting the SML
NSString *cookieCheck = [[[NSString alloc] initWithData:cookieData encoding:NSUTF8StringEncoding] autorelease];
NSLog(@"yum yum feed me more cookie!! %@",cookieCheck);
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
[connectionInProgress release];
connectionInProgress = nil;
[cookieData release];
cookieData = nil;
NSString *errorString = [NSString stringWithFormat:@"Fetch failed: %@", [error localizedDescription]];
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:errorString delegate:nil cancelButtonTitle:@"OK" destructiveButtonTitle:nil otherButtonTitles:nil];
[actionSheet showInView:[UIApplication mainWindow]];[B][COLOR="Red"] //UIApplication may not respond to '+mainWindow'[/COLOR][/B]
[actionSheet autorelease];
}
//***** other code till end.
@end
Last edited: