Search Results

Search found 560 results on 23 pages for 'nsdictionary'.

Page 10/23 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • Why doesn't my UIViewController class keep track of an NSArray instance variable.

    - by TaoStoner
    Hey, I am new to Objective-C 2.0 and Xcode, so forgive me if I am missing something elementary here. Anyways, I am trying to make my own UIViewController class called GameView to display a new view. To work the game I need to keep track of an NSArray that I want to load from a plist file. I have made a method 'loadGame' which I want to load the correct NSArray into an instance variable. However it appears that after the method executes the instance variable loses track of the array. Its easier if I just show you the code.... @interface GameView : UIViewController { IBOutlet UIView *view IBOutlet UILabel *label; NSArray *currentGame; } -(IBOutlet)next; -(void)loadDefault; ... @implementation GameView - (IBOutlet)next{ int numElements = [currentGame count]; int r = rand() % numElements; NSString *myString = [currentGame objectAtIndex:(NSUInteger)r]; [label setText: myString]; } - (void)loadDefault { NSDictionary *games; NSString *path = [[NSBundle mainBundle] bundlePath]; NSString *finalPath = [path stringByAppendingPathComponent:@"Games.plist"]; games = [NSDictionary dictionaryWithContentsOfFile:finalPath]; currentGame = [games objectForKey:@"Default"]; } when loadDefault gets called, everything runs perfectly, but when I try to use the currentGame NSArray later in the method call to next, currentGame appears to be nil. I am also aware of the memory management issues with this code. Any help would be appreciated with this problem.

    Read the article

  • Iphone xcode simulator crashes when I move up and down on a table row

    - by Frames84
    I can't get my head round this. When the page loads, everything works fine - I can drill up and down, however 'stream' (in the position I have highlighted below) becomes not equal to anything when I pull up and down on the tableview. But the error is only sometimes. Normally it returns key/pairs. If know one can understand above how to you test for // (int)[$VAR count]} key/value pairs in a NSMutableDictionary object - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *FirstLevelCell = @"FirstLevelCell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:FirstLevelCell]; if(cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:FirstLevelCell] autorelease]; } NSInteger row = [indexPath row]; //NSDictionary *stream = (NSDictionary *) [dataList objectAtIndex:row]; NSString *level = self.atLevel; if([level isEqualToString:@"level2"]) { NSMutableDictionary *stream = [[NSMutableArray alloc] init]; stream = (NSMutableDictionary *) [dataList objectAtIndex:row]; // stream value is (int)[$VAR count]} key/value pairs if ([stream valueForKey:@"title"] ) { cell.textLabel.text = [stream valueForKey:@"title"]; cell.textLabel.numberOfLines = 2; cell.textLabel.font =[UIFont systemFontOfSize:10]; NSString *detailText = [stream valueForKey:@"created"]; cell.detailTextLabel.numberOfLines = 2; cell.detailTextLabel.font= [UIFont systemFontOfSize:9]; cell.detailTextLabel.text = detailText; NSString *str = @"http://www.mywebsite.co.uk/images/stories/Cimex.jpg"; NSData *imageURL = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:str]]; UIImage *newsImage = [[UIImage alloc] initWithData:imageURL]; cell.imageView.image = newsImage; [stream release]; } } else { cell.textLabel.text = [dataList objectAtIndex:row]; } return cell; } Thanks for your time

    Read the article

  • How can I retain the data stored in plist from UITextField when application is restarted ?

    - by srikanth rongali
    I am using the plist to store the data entered in the UITextFields. But, when I restart my application all the data entered previously was deleted. How can I retain the data in the Plist. I have a UITableView and when a cell is touched a view appears with two UITextFields. nameField and descriptionField. I stored the data in this way. My code is. -(void)save:(id)sender { indexOfDataArray = temp; //the cell selected in table view. NSString *string1 = [[NSString alloc]init]; NSString *string2 = [[NSString alloc]init]; string1 = nameField.text; string2 = descriptionField.text; NSDictionary *myDict = [[NSDictionary alloc] initWithObjectsAndKeys:string2, string1, nil]; [myArray addObject:myDict]; //myArray is NSMutableArray declared in tableViewController class. //[myArray insertObject:myDict atIndex:indexOfDataArray]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *path = [documentsDirectory stringByAppendingPathComponent:@"tableVideoData.plist"]; [myArray writeToFile:path atomically:YES]; UIAlertView *alertMesage = [[UIAlertView alloc] initWithTitle: @"Save Alert" message:@"The data entered is saved" delegate:nil cancelButtonTitle:@"cancel" otherButtonTitles:nil] ; [alertMesage show]; [alertMesage release]; } When I am using the [myArray insertObject:myDict atIndex:indexOfDataArray]; It is giving the error *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSCFArray insertObject:atIndex:]: index (2) beyond bounds (1)' So I used [myArray addObject:myDict]; Please help me, how can I retain the data in plist. Thank You.

    Read the article

  • problems getting HTTPRiot working

    - by bwizzy
    I've got an iphone app where I'm trying to use HTTPRiot to make some API calls to a web app. Problem is I can't see that none of the HTTPRiot delegate methods are being called. I've got a log in all the delegate methods, and I'm also looking at the webserver log. I see that the URL is being hit. //API.h #import <Foundation/Foundation.h> #include <HTTPRiot/HTTPRiot.h> @interface API : HRRestModel { } +(void)runTest; @end //API.m #import "API.h" @implementation API + (void)initialize { NSLog(@"api initialize"); [self setDelegate:self]; [self setBaseURL:[NSURL URLWithString:@"http://localhost:3000/api"]]; [self setBasicAuthWithUsername:@"demo" password:@"123456"]; NSDictionary *params = [NSDictionary dictionaryWithObject:@"1234567" forKey:@"api_key"]; [self setDefaultParams:params]; }//end initialize +(void)runTest { NSLog(@"api run test"); // Would send a request to http://localhost:1234/api/people/1?api_key=1234567 [self getPath:@"/save_diet" withOptions:nil object:nil]; } +(void)restConnection:(NSURLConnection *)connection didReturnResource:(id)resource object:(id)object { NSLog(@"didReturnResource"); } +(void)restConnection:(NSURLConnection *)connection didReceiveResponse:(NSHTTPURLResponse *)response object:(id)object { NSLog(@"didReceiveResponse"); } +(void)restConnection:(NSURLConnection *)connection didReceiveParseError:(NSError *)error responseBody:(NSString *)body object:(id)object { NSLog(@"didReceiveParseError"); } +(void)restConnection:(NSURLConnection *)connection didReceiveError:(NSError *)error response:(NSHTTPURLResponse *)response object:(id)object { NSLog(@"didReceiveError"); } +(void)restConnection:(NSURLConnection *)connection didFailWithError:(NSError *)error object:(id)object { NSLog(@"didFailWithError"); } @end //test code [API runTest]; //log output

    Read the article

  • How to fix a slow scrolling table view

    - by hanumanDev
    I have a table view that's scrolling slowly. Does anyone know why that might be? There is an image for each row, but even after the images are loaded it still stutters and scrolls slowly. thanks for any help here's my code: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *simpleTableIdentifier = @"SimpleTableCell"; SimpleTableCell *cell = (SimpleTableCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier]; if (cell == nil) { NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"SimpleTableCell" owner:self options:nil]; cell = [nib objectAtIndex:0]; } // Get item from tableData NSDictionary *item = (NSDictionary *)[displayItems objectAtIndex:indexPath.row]; // display the youdeal deal image photoString = [item objectForKey:@"image"]; UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:photoString]]]; cell.titleLabel.text = [item objectForKey:@"supercat"]; cell.descriptionLabel.text = [item objectForKey:@"title"]; NSString *convertedLeftCount = [NSString stringWithFormat:@"%@",[item objectForKey:@"left_count"]]; cell.amountLabel.text = convertedLeftCount; cell.thumbnailImageView.image = image; cell.priceLabel.text = [item objectForKey:@"cat"]; return cell; }

    Read the article

  • create CLLocationCoordinate2D from array

    - by shani
    I have a plist with dictionary of array's with coordinates (stored as strings). I want to create a CLLocationCoordinate2D from every array and crate an overlay for the map. I did that - NSString *thePath = [[NSBundle mainBundle] pathForResource:@"Roots" ofType:@"plist"]; NSDictionary *pointsDic = [[NSDictionary alloc] initWithContentsOfFile:thePath]; NSArray *pointsArray = [NSArray arrayWithArray:[pointsDic objectForKey:@"roade1"]]; CLLocationCoordinate2D pointsToUse[256]; for(int i = 0; i < 256; i++) { CGPoint p = CGPointFromString([pointsArray objectAtIndex:i]); pointsToUse[i] = CLLocationCoordinate2DMake(p.x,p.y); NSLog(@"coord %f",pointsToUse [i].longitude); NSLog(@"coord %f",pointsToUse [i].latitude); } MKPolyline *myPolyline = [MKPolyline polylineWithCoordinates:pointsToUse count:256]; [[self mv] addOverlay:myPolyline]; but the app is crashing without any error. (BTW when i remove the addOverLay method the app does not crash). I have 2 questions- What am i doing wrong? I have tried to set the pointsArray count as the argument for the CLLocationCoordinate2D like that - CLLocationCoordinate2D pointsToUse[pointsArray count]; And i am getting an error. How can i set the CLLocationCoordinate2D dynamically ? Thanks for any help. Shani

    Read the article

  • Saving Email/Password to Keychain in iOS

    - by Jason
    I'm very new to iOS development so forgive me if this is a newbie question. I have a simple authentication mechanism for my app that takes a user's email address and password. I also have a switch that says 'Remember me'. If the user toggles that switch on, I'd like to preserve their email/password so those fields can be auto-populated in the future. I've gotten this to work with saving to a plist file but I know that's not the best idea since the password is unencrypted. I found some sample code for saving to the keychain, but to be honest, I'm a little lost. For the function below, I'm not sure how to call it and how to modify it to save the email address as well. I'm guessing to call it would be: saveString(@"passwordgoeshere"); Thank you for any help!!! + (void)saveString:(NSString *)inputString forKey:(NSString *)account { NSAssert(account != nil, @"Invalid account"); NSAssert(inputString != nil, @"Invalid string"); NSMutableDictionary *query = [NSMutableDictionary dictionary]; [query setObject:(id)kSecClassGenericPassword forKey:(id)kSecClass]; [query setObject:account forKey:(id)kSecAttrAccount]; [query setObject:(id)kSecAttrAccessibleWhenUnlocked forKey:(id)kSecAttrAccessible]; OSStatus error = SecItemCopyMatching((CFDictionaryRef)query, NULL); if (error == errSecSuccess) { // do update NSDictionary *attributesToUpdate = [NSDictionary dictionaryWithObject:[inputString dataUsingEncoding:NSUTF8StringEncoding] forKey:(id)kSecValueData]; error = SecItemUpdate((CFDictionaryRef)query, (CFDictionaryRef)attributesToUpdate); NSAssert1(error == errSecSuccess, @"SecItemUpdate failed: %d", error); } else if (error == errSecItemNotFound) { // do add [query setObject:[inputString dataUsingEncoding:NSUTF8StringEncoding] forKey:(id)kSecValueData]; error = SecItemAdd((CFDictionaryRef)query, NULL); NSAssert1(error == errSecSuccess, @"SecItemAdd failed: %d", error); } else { NSAssert1(NO, @"SecItemCopyMatching failed: %d", error); } }

    Read the article

  • Core Data migration failing with error: Failed to save new store after first pass of migration

    - by unforgiven
    In the past I had already implemented successfully automatic migration from version 1 of my data model to version 2. Now, using SDK 3.1.3, migrating from version 2 to version 3 fails with the following error: Unresolved error Error Domain=NSCocoaErrorDomain Code=134110 UserInfo=0x5363360 "Operation could not be completed. (Cocoa error 134110.)", { NSUnderlyingError = Error Domain=NSCocoaErrorDomain Code=256 UserInfo=0x53622b0 "Operation could not be completed. (Cocoa error 256.)"; reason = "Failed to save new store after first pass of migration."; } I have tried automatic migration using NSMigratePersistentStoresAutomaticallyOption and NSInferMappingModelAutomaticallyOption and also migration using only NSMigratePersistentStoresAutomaticallyOption, providing a mapping model from v2 to v3. I see the above error logged, and no object is available in the application. However, if I quit the application and reopen it, everything is in place and working. The Core Data methods I am using are the following ones - (NSManagedObjectModel *)managedObjectModel { if (managedObjectModel != nil) { return managedObjectModel; } NSString *path = [[NSBundle mainBundle] pathForResource:@"MYAPP" ofType:@"momd"]; NSURL *momURL = [NSURL fileURLWithPath:path]; managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:momURL]; return managedObjectModel; } - (NSManagedObjectContext *) managedObjectContext { if (managedObjectContext != nil) { return managedObjectContext; } NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator]; if (coordinator != nil) { managedObjectContext = [[NSManagedObjectContext alloc] init]; [managedObjectContext setPersistentStoreCoordinator: coordinator]; } return managedObjectContext; } - (NSPersistentStoreCoordinator *)persistentStoreCoordinator { if (persistentStoreCoordinator != nil) { return persistentStoreCoordinator; } NSURL *storeUrl = [NSURL fileURLWithPath: [[self applicationDocumentsDirectory] stringByAppendingPathComponent: @"MYAPP.sqlite"]]; NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil]; NSError *error = nil; persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel: [self managedObjectModel]]; if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:options error:&error]) { // Handle error NSLog(@"Unresolved error %@, %@", error, [error userInfo]); } return persistentStoreCoordinator; } In the simulator, I see that this generates a MYAPP~.sqlite files and a MYAPP.sqlite file. I tried to remove the MYAPP~.sqlite file, but BOOL oldExists = [[NSFileManager defaultManager] fileExistsAtPath: [[self applicationDocumentsDirectory] stringByAppendingPathComponent: @"MYAPP~.sqlite"]]; always returns NO. Any clue? Am I doing something wrong? Thank you in advance.

    Read the article

  • iPad application crash in Apple review - cannot replicate in simulator, have crash log

    - by Mike
    I am clearly missing something obvious here and would really appreciate some input. I have tried repeatedly to submit an application to Apple (iPad in this case) that is crashing on their end when testing but I cannot replicated the situation on my end (obviously I only have the damned simulator to work with at this point). The crash log is as follows: Date/Time: 2010-04-01 05:39:47.226 -0700 OS Version: iPhone OS 3.2 (7B367) Report Version: 104 Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x00000000, 0x00000000 Crashed Thread: 0 Thread 0 Crashed: 0 libSystem.B.dylib 0x000790a0 __kill + 8 1 libSystem.B.dylib 0x00079090 kill + 4 2 libSystem.B.dylib 0x00079082 raise + 10 3 libSystem.B.dylib 0x0008d20a abort + 50 4 libstdc++.6.dylib 0x00044a1c __gnu_cxx::__verbose_terminate_handler() + 376 5 libobjc.A.dylib 0x000057c4 _objc_terminate + 104 6 libstdc++.6.dylib 0x00042dee __cxxabiv1::__terminate(void (*)()) + 46 7 libstdc++.6.dylib 0x00042e42 std::terminate() + 10 8 libstdc++.6.dylib 0x00042f12 __cxa_throw + 78 9 libobjc.A.dylib 0x000046a4 objc_exception_throw + 64 10 CoreFoundation 0x00090c6e +[NSException raise:format:arguments:] + 74 11 CoreFoundation 0x00090d38 +[NSException raise:format:] + 28 12 Foundation 0x00002600 -[NSCFDictionary setObject:forKey:] + 184 13 iPadMosaic 0x00003282 -[iPadMosaicViewController getAlbumThumbs] (iPadMosaicViewController.m:468) 14 Foundation 0x000728fe __NSFireDelayedPerform + 314 15 CoreFoundation 0x00022d1c CFRunLoopRunSpecific + 2092 16 CoreFoundation 0x000224da CFRunLoopRunInMode + 42 17 GraphicsServices 0x000030d4 GSEventRunModal + 108 18 GraphicsServices 0x00003180 GSEventRun + 56 19 UIKit 0x000034c2 -[UIApplication _run] + 374 20 UIKit 0x000019ec UIApplicationMain + 636 21 iPadMosaic 0x00002234 main (main.m:14) 22 iPadMosaic 0x00002204 start + 32 My understanding here is that I am botching the Dictionary add somehow. The relevant lines of code are: for (NSDictionary *album in self.albumList) { // Get image for each album cover UIImage *albumCover; // Loop through photos to get URL of cover based on photo ID match NSString *coverURL = @""; for (NSDictionary *photo in self.photoList) { if ([[photo objectForKey:@"pid"] isEqualToString:[album objectForKey:@"cover_pid"]]) { coverURL = [photo objectForKey:@"src"]; } } NSURL *albumCoverURL = [NSURL URLWithString:coverURL]; NSData *albumCoverData = [NSData dataWithContentsOfURL:albumCoverURL]; albumCover = [UIImage imageWithData:albumCoverData]; if (albumCover == nil || albumCover == NULL) { //NSLog(@"No album cover for some reason"); albumCover = [UIImage imageNamed:@"noImage.png"]; } [[self.albumList objectAtIndex:albumCurrent] setObject:albumCover forKey:@"coverThumb"]; } This is part of a loop that runs over the existing dictionaries stored in an array. If retrieving the album cover fails for some reason the object is filled with a default image and then added. The last line of the code is what's showing up in the crash log. It runs fine in the simulator but crashes 100% in testing on device apparently. Can anyone tell me what I am missing here?

    Read the article

  • Convert charset name to NSStringEncoding

    - by d11wtq
    Given a charset string, such as "utf-8", "iso-8859-1", "us-ascii" etc, is there any built-in way to get the appropriate NSStringEncoding in Cocoa? Right now I'm looking at just building a NSDictionary containing a canonicalized version of the name mapped to the NSStringEncoding, then having a lookup mechanism that canonicalizes the input in the same way. But is there really no way to get NSUTF8StringEncoding given the string "UTF-8", etc?

    Read the article

  • No visible @interface for 'AppDelegate' declares the selector

    - by coolhongly
    I'm now writing a registration screen before my tabBar shows up. My idea is to show my registration screen through this method (no dismiss function for now): - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. Register *registerView = [[Register alloc] initWithNibName:nil bundle:nil]; [self presentModalViewController:registerView animated:YES]; return YES; } Which is in AppDelegate.m Unfortunately it doesn't work. Could you help me solve this please?

    Read the article

  • UIImagePickerController in iPhone OS 3.0

    - by Biranchi
    Hi all, I am using iPhone OS 3.0 SDK. My requirement is that I want to get the image from the photo albums library and display it on an image view. I am using the "UIImagePickerController" for that. But the problem is the "- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)imageeditingInfo:(NSDictionary *)editingInfo" delegate method is deprecated in iPhone OS 3.0 , so is there any alternative for getting the Image from the UIImagePickerController. All suggestions are highly appreciated. Thanks...

    Read the article

  • Migration Core Data error code 134130

    - by magichero
    I want to do migration with 2 core database. I have read apple developer document. For the first database, I add some attributes (string, integer and date properties) to new version database. And follow all steps, I have done migration successfully with the first once. But the second database, I also add attributes (string, integer, date, transformable and binary-data properties) to new version database. And follow all steps (like the first database) but system return an error (134130). Here is the code: if (persistentStoreCoordinator_) { PMReleaseSafely(persistentStoreCoordinator_); } // Notify NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; [nc postNotificationName:GCalWillMigrationNotification object:self]; // NSString *sourceStoreType = NSSQLiteStoreType; NSString *dataStorePath = [PMUtility dataStorePathForName:GCalDBWarehousePersistentStoreName]; NSURL *storeURL = [NSURL fileURLWithPath:dataStorePath]; BOOL storeExists = [[NSFileManager defaultManager] fileExistsAtPath:dataStorePath]; // NSError *error = nil; NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil]; persistentStoreCoordinator_ = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:self.managedObjectModel]; [persistentStoreCoordinator_ addPersistentStoreWithType:sourceStoreType configuration:nil URL:storeURL options:options error:&error]; if (error != nil) { abort(); } error is not nil and below is log: Error Domain=NSCocoaErrorDomain Code=134130 "The operation couldn\u2019t be completed. (Cocoa error 134130.)" UserInfo=0x856f790 {URL=file://localhost/Users/greensun/Library/Application%20Support/iPhone%20Simulator/5.0/Applications/D10712DE-D9FE-411A-8182-C4F58C60EC6D/Library/Application%20Support/Promise%20Mail/GCalDBWarehouse.sqlite, metadata={type = immutable dict, count = 7, entries = 2 : {contents = "NSStoreModelVersionIdentifiers"} = {type = immutable, count = 1, values = ( 0 : {contents = ""} )} 4 : {contents = "NSPersistenceFrameworkVersion"} = {value = +386, type = kCFNumberSInt64Type} 6 : {contents = "NSStoreModelVersionHashes"} = {type = immutable dict, count = 2, entries = 0 : {contents = "SyncEvent"} = {length = 32, capacity = 32, bytes = 0xfdae355f55c13fbd0344415fea26c8bb ... 4c1721aadd4122aa} 1 : {contents = "ImportEvent"} = {length = 32, capacity = 32, bytes = 0x7676888f0d7eaff4d1f844343028ce02 ... 040af6cbe8c5fd01} } 7 : {contents = "NSStoreUUID"} = {contents = "51678BAC-CCFB-4D00-AF5C-8FA1BEDA6440"} 8 : {contents = "NSStoreType"} = {contents = "SQLite"} 9 : {contents = "_NSAutoVacuumLevel"} = {contents = "2"} 10 : {contents = "NSStoreModelVersionHashesVersion"} = {value = +3, type = kCFNumberSInt32Type} }, reason=Can't find model for source store} I try a lot of solutions but it does not work. I just add more attributes to 2 new version database, and succeed in migrating once. Thanks for reading and your help.

    Read the article

  • problem while finding iphone memory programatically

    - by sneha
    I am facing a strange problem with my iphone. It shows available memory as 278 Mb from settings and also in the itunes . But when i find it programatically like this NSDictionary *fileSystemAttributes = [[NSFileManager defaultManager] attributesOfFileSystemForPath:NSHomeDirectory() error:&error]; double availableSpace = [[fileSystemAttributes objectForKey:NSFileSystemFreeSize] floatValue]; I am getting it as 458.0 Mb. Can any one help me out why i m having so much difference between both the values ?? As both the values should be same Thanks in advance

    Read the article

  • ASIHttpRequest problems. "unrecognized selector sent to instance"

    - by Paul Peelen
    Hi, I am experiencing problems using ASIHttpRequst. This is the error I get: 2010-04-11 20:47:08.176 citybikesPlus[5885:207] *** -[CALayer rackDone:]: unrecognized selector sent to instance 0x464a890 2010-04-11 20:47:08.176 citybikesPlus[5885:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[CALayer rackDone:]: unrecognized selector sent to instance 0x464a890' 2010-04-11 20:47:08.176 citybikesPlus[5885:207] Stack: ( 33936475, 2546353417, 34318395, 33887862, 33740482, 126399, 445238, 33720545, 33717320, 40085013, 40085210, 3108783, 11168, 11022 ) And this is my code (Part of it): // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [image setImage:[UIImage imageNamed:@"bullet_rack.png"]]; BikeAnnotation *bike = [[annotationView annotation] retain]; bike._sub = @""; [super viewDidLoad]; NSString *newUrl = [[NSString alloc] initWithFormat:rackUrl, bike._id]; NSString *fetchUrl = [newUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; [networkQueue cancelAllOperations]; [networkQueue setRequestDidFinishSelector:@selector(rackDone:)]; [networkQueue setRequestDidFailSelector:@selector(processFailed:)]; [networkQueue setDelegate:self]; ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:[NSURL URLWithString:fetchUrl]] retain]; [request setDefaultResponseEncoding:NSUTF8StringEncoding]; [networkQueue addOperation:request]; [networkQueue go]; } - (void)rackDone:(ASIHTTPRequest *)request { NSString *resultSearch = [request responseString]; NSData *data = [resultSearch dataUsingEncoding:NSUTF8StringEncoding]; NSString *errorDesc = nil; NSPropertyListFormat format; NSDictionary * dict = (NSDictionary*)[NSPropertyListSerialization propertyListFromData:data mutabilityOption:NSPropertyListMutableContainersAndLeaves format:&format errorDescription:&errorDesc]; rackXmlResult* fileResult = [[[rackXmlResult alloc] initWithDictionary:dict] autorelease]; rackXmlSet *rackSet = [fileResult getRackResult]; NSString *subString = [[NSString alloc] initWithFormat:@"Cyklar tillgängligt: %@ -- Lediga platser: %@", rackSet._ready_bikes, rackSet._empty_locks]; [activity setHidden:YES]; [image setHidden:NO]; BikeAnnotation *bike = [annotationView annotation]; bike._sub = subString; } - (void) processFailed:(ASIHTTPRequest *)request { UIAlertView *errorView; NSError *error = [request error]; NSString *errorString = [error localizedDescription]; errorView = [[UIAlertView alloc] initWithTitle: NSLocalizedString(@"Network error", @"Network error") message: errorString delegate: self cancelButtonTitle: NSLocalizedString(@"Close", @"Network error") otherButtonTitles: nil]; [errorView show]; [errorView autorelease]; } The process is loaded as LeftCalloutView in the callout bubble when annotations are loaded in my mapview, so quite a lot (80 times or so). It is meant to retrieve a XML Plist from a server, parse it and use the data... but it dies at the rackDone: Does anybody have any ideas? Regards, Paul Peelen

    Read the article

  • How can I get image data from QTKit without color or gamma correction in Snow Leopard?

    - by Nick Haddad
    Since Snow Leopard, QTKit is now returning color corrected image data from functions like QTMovies frameImageAtTime:withAttributes:error:. Given an uncompressed AVI file, the same image data is displayed with larger pixel values in Snow Leopard vs. Leopard. Currently I'm using frameImageAtTime to get an NSImage, then ask for the tiffRepresentation of that image. After doing this, pixel values are slightly higher in Snow Leopard. For example, a file with the following pixel value in Leopard: [0 180 0] Now has a pixel value like: [0 192 0] Is there any way to ask a QTMovie for video frames that are not color corrected? Should I be asking for a CGImageRef, CIImage, or CVPixelBufferRef instead? Is there a way to disable color correction altogether prior to reading in the video files? I've attempted to work around this issue by drawing into a NSBitmapImageRep with the NSCalibratedColroSpace, but that only gets my part of the way there: // Create a movie NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys : nsFileName, QTMovieFileNameAttribute, [NSNumber numberWithBool:NO], QTMovieOpenAsyncOKAttribute, [NSNumber numberWithBool:NO], QTMovieLoopsAttribute, [NSNumber numberWithBool:NO], QTMovieLoopsBackAndForthAttribute, (id)nil]; _theMovie = [[QTMovie alloc] initWithAttributes:dict error:&error]; // .... NSMutableDictionary *imageAttributes = [NSMutableDictionary dictionary]; [imageAttributes setObject:QTMovieFrameImageTypeNSImage forKey:QTMovieFrameImageType]; [imageAttributes setObject:[NSArray arrayWithObject:@"NSBitmapImageRep"] forKey: QTMovieFrameImageRepresentationsType]; [imageAttributes setObject:[NSNumber numberWithBool:YES] forKey:QTMovieFrameImageHighQuality]; NSError* err = nil; NSImage* image = (NSImage*)[_theMovie frameImageAtTime:frameTime withAttributes:imageAttributes error:&err]; // copy NSImage into an NSBitmapImageRep (Objective-C) NSBitmapImageRep* bitmap = [[image representations] objectAtIndex:0]; // Draw into a colorspace we know about NSBitmapImageRep *bitmapWhoseFormatIKnow = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL pixelsWide:getWidth() pixelsHigh:getHeight() bitsPerSample:8 samplesPerPixel:4 hasAlpha:YES isPlanar:NO colorSpaceName:NSCalibratedRGBColorSpace bitmapFormat:0 bytesPerRow:(getWidth() * 4) bitsPerPixel:32]; [NSGraphicsContext saveGraphicsState]; [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithBitmapImageRep:bitmapWhoseFormatIKnow]]; [bitmap draw]; [NSGraphicsContext restoreGraphicsState]; This does convert back to a 'Non color corrected' colorspace, but the color values NOT are exactly the same as what is stored in the Uncompressed AVI files we are testing with. Also this is much less efficient because it is converting from RGB - "Device RGB" - RGB. Also, I am working in a 64-bit application, so dropping down to the Quicktime-C API is not an option. Thanks for your help.

    Read the article

  • Register/Set a new language default

    - by mongeta
    Hello, My app has some languages that the user can change whenever wants. The problem is that always uses the current device language selected, so at least my localizable strings are working as expected, but no matter wich language I set, I'm getting alwats the default selected of the device. Where I have to call this code? [[NSUserDefaults standardUserDefaults] registerDefaults: [NSDictionary dictionaryWithObject:[NSArray arrayWithObjects:@"ca", @"en", nil] forKey:@"AppleLanguages"]]; Currently I'm calling from the AppDelegate implementation file: - (void)applicationDidFinishLaunching:(UIApplication *)application { Thanks, r.

    Read the article

  • iPhone: Speeding up a search that's polling 17,000 Core Data objects

    - by randombits
    I have a class that conforms to UISearchDisplayDelegate and contains a UISearchBar. This view is responsible for allowing the user to poll a store of about 17,000 objects that are currently managed by Core Data. Everytime the user types in a character, I created an instance of a SearchOperation (subclasses NSOperation) that queries Core Data to find results that might match the search. The code in the search controller looks something like: - (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope { // Update the filtered array based on the search text and scope in a secondary thread if ([searchText length] < 3) { [filteredList removeAllObjects]; // First clear the filtered array. [self setFilteredList:NULL]; [self.tableView reloadData]; return; } NSDictionary *searchdict = [NSDictionary dictionaryWithObjectsAndKeys:scope, @"scope", searchText, @"searchText", nil]; [aSearchQueue cancelAllOperations]; SearchOperation *searchOp = [[SearchOperation alloc] initWithDelegate:self dataDict:searchdict]; [aSearchQueue addOperation:searchOp]; } And my search is rather straight forward. SearchOperation is a subclass of NSOperation. I overwrote the main method with the following code: - (void)main { if ([self isCancelled]) { return; } NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"MyEntity" inManagedObjectContext:managedObjectContext]; NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; [fetchRequest setEntity:entity]; NSPredicate *predicate = NULL; predicate = [NSPredicate predicateWithFormat:@"(someattr contains[cd] %@)", searchText]; [fetchRequest setPredicate:predicate]; NSError *error = NULL; NSArray *fetchResults = [managedObjectContext executeFetchRequest:fetchRequest error:&error]; [fetchRequest release]; if (self.delegate != nil) [self.delegate didFinishSearching:fetchResults]; [pool drain]; } This code works, but it has several issues. It's slow. Even though I have the search happening in a separate thread other than the UI thread, querying 17,000 objects is clearly not optimal. If I'm not careful, crashes can happen. I set the max concurrent searches in my NSOperationQueue to 1 to avoid this. What else can I do to make this search faster? I think preloading all 17,000 objects into memory might be risky. There has to be a smarter way to conduct this search to give results back to the user faster.

    Read the article

  • How to handle an array of pointers in Objective-C

    - by DougW
    I figured out the answer to this question, but I couldn't find the solution on here, so posting it for posterity. So, in Objective-C, how do you create an object out of a pointer in order to store it in objective-c collections (NSArray, NSDictionary, NSSet, etc) without reverting to regular C?

    Read the article

  • Preserving alpha issues with loaded UIImages - how to avoid discarding alpha values on import?

    - by Peter Hajas
    My application lets the user save/load images with alpha values to the camera roll on the device. I can see in the Photos application that these images are appropriately alpha'd, as alpha'd areas just appear black. However, when I load these images back into the application using the valueForKey:UIImagePickerControllerOriginalImage message to the info dictionary from (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info, the alpha values are turned to just white, making those sections opaque. Is there a way to preserve these alpha values?

    Read the article

  • wait after presentModalViewController

    - by Cesar
    I need to wait (don't execute the code) after the presentModalViewController until the modal view it's dismissed, it's possible or it's a conceptual error ? -(NSDictionary *)authRequired { [self presentModalViewController:loginRegView animated:YES]; //This view write the settings when dismissed. NSMutableDictionary *ret=[[NSMutableDictionary alloc] init]; [ret setObject:[app.settings get:@"user"] forKey:@"user"]; [ret setObject:[app.settings get:@"pass"] forKey:@"pass"]; return ret; }

    Read the article

  • Convert NSFileSystemSize to Gigabytes

    - by AWright4911
    I need to convert NSFileSystemSize to Gigabytes. NSDictionary * fsAttributes = [ [NSFileManager defaultManager] fileSystemAttributesAtPath:NSTemporaryDirectory()]; NSNumber *totalSize = [fsAttributes objectForKey:NSFileSystemSize]; NSString *sizeInGB = [NSString stringWithFormat:@"\n\n %3.2f GB",[totalSize floatValue] / 107374824]; //returns 69.86 GB any ideas why it doesnt return at leat 8.0GB's?

    Read the article

  • Add 1.6.0 Cordova plugin to 2.2.0 Cordova project

    - by BlackFlam3
    How do I add a cordova plugin made on 1.6.0 to a 2.2.0 cordova project for iOS? Upgrade the 1.6.0 project to 1.7.0, then 1.8.0 and so on (doesn't feel right)? Or how do I resolve the current callback signature on the new Cordova(2.2.0) that uses "(CDInvokedURL *)command" as parameter instead of (NSDictionary *)options? More specifically, I am trying to add the Calendar Plugin for iOS to a Cordova 2.2.0 project.

    Read the article

  • KVO on the "windows" value of UIApplication?

    - by Ariel Malka
    The following is not working: [[UIApplication sharedApplication] addObserver:self forKeyPath:@"windows" options:(NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld) context:NULL]; Together with that, on the Observer side: - (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { NSLog(@"never reached!"); } Any clues? N.B. My uber-goal is to get a notification when a (system-generated) UIAlertView is shown.

    Read the article

  • EXC_BAD_ACCESS when scrolling table after json data is imported

    - by Michael Robinson
    Hello, I'm having a bear of a time trying to figure out why I'm getting a EXC_BAD ACCESS error. The console is giving me this eror: " -[CFArray objectAtIndex:]: message sent to deallocated instance 0x3b14110", I Can't figure it out...Thanks in advance. // Customize the number of rows in the table view. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [rows count]; } // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease]; } // Configure the cell. NSDictionary *dict = [rows objectAtIndex: indexPath.row]; cell.textLabel.text = [dict objectForKey:@"name"]; cell.detailTextLabel.text = [dict objectForKey:@"age"]; return cell; } // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:0.0/255.0 green:207.0/255.0 blue:255.0/255.0 alpha:1.0]; self.title = NSLocalizedString(@"How Big Now", @"How Big Now"); NSURL *url = [NSURL URLWithString:@"http://10.0.1.8/~imac/iphone/jsontest.php"]; NSString *jsonreturn = [[NSString alloc] initWithContentsOfURL:url]; // NSLog(jsonreturn); // Look at the console and you can see what the restults are NSData *jsonData = [jsonreturn dataUsingEncoding:NSUTF32BigEndianStringEncoding]; NSError *error = nil; // In "real" code you should surround this with try and catch NSDictionary * dict = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&error]; if (dict) { rows = [dict objectForKey:@"member"]; } NSLog(@"Array: %@",rows); [jsonreturn release]; } - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } - (void)viewDidUnload { // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } - (void)dealloc { [super dealloc]; } @end

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >