Search Results

Search found 290 results on 12 pages for 'nsnumber'.

Page 6/12 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • iPhone keyboard's return key will move curser to next textfield

    - by iAm
    Hello Fellow Koder ••• I have a TableViewController that is using a grouped Style and has two(2) sections. The first section has 4 rows and the second section has 3 rows. I have placed a UILabel and a UITextField in each cell, and have a custom method(textFieldDone:) to handle the cursor movement to the next text field when the return key is press. This works fine and dandy if there is only one section, but I have two :( and yes I need two:) so I started koden' up an answer, but got results that just don't work, I did notice during my debugging that cell Identifier (I use Two) is only showing the one (in the debug consol) and it's the first one only (Generic Cell). - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = nil; switch (indexPath.section) { case AUTO_DETAILS: { static NSString *cellID = @"GenericCell"; cell = [tableView dequeueReusableCellWithIdentifier:cellID]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:cellID] autorelease]; UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 75, 25)]; label.tag = kLabelTag; label.font = [UIFont boldSystemFontOfSize:14]; label.textAlignment = UITextAlignmentRight; [cell.contentView addSubview:label]; [label release]; UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(90, 12, 200, 25)]; textField.clearsOnBeginEditing = NO; [textField setDelegate:self]; [textField addTarget:self action:@selector(topTextFieldDone:) forControlEvents:UIControlEventEditingDidEndOnExit]; [cell.contentView addSubview:textField]; } NSInteger row = [indexPath row]; UILabel *label = (UILabel *)[cell viewWithTag:kLabelTag]; UITextField *textField = nil; for (UIView *oneView in cell.contentView.subviews) { if ([oneView isMemberOfClass:[UITextField class]]) textField = (UITextField *)oneView; } label.text = [topCellLabels objectAtIndex:row]; NSNumber *rowAsNum = [[NSNumber alloc] initWithInt:row]; switch (row) { case kMakeRowIndex: if ([[tempValues allKeys] containsObject:rowAsNum]) textField.text = [tempValues objectForKey:rowAsNum]; else textField.text = automobile.make; break; case kModelRowIndex: if ([[tempValues allKeys] containsObject:rowAsNum]) textField.text = [tempValues objectForKey:rowAsNum]; else textField.text = automobile.model; break; case kYearRowIndex: if ([[tempValues allKeys] containsObject:rowAsNum]) textField.text = [tempValues objectForKey:rowAsNum]; else textField.text = automobile.year; break; case kNotesRowIndex: if ([[tempValues allKeys] containsObject:rowAsNum]) textField.text = [tempValues objectForKey:rowAsNum]; else textField.text = automobile.notes; break; default: break; } if (textFieldBeingEdited == textField) { textFieldBeingEdited = nil; } textField.tag = row; [rowAsNum release]; break; } case AUTO_REGISTRATION: { static NSString *AutoEditCellID = @"AutoEditCellID"; cell = [tableView dequeueReusableCellWithIdentifier:AutoEditCellID]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:AutoEditCellID] autorelease]; UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 75, 25)]; label.tag = kLabelTag; label.font = [UIFont boldSystemFontOfSize:14]; label.textAlignment = UITextAlignmentRight; [cell.contentView addSubview:label]; [label release]; UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(90, 12, 200, 25)]; textField.clearsOnBeginEditing = NO; [textField setDelegate:self]; [textField addTarget:self action:@selector(bottomTextFieldDone:) forControlEvents:UIControlEventEditingDidEndOnExit]; [cell.contentView addSubview:textField]; } NSInteger row = [indexPath row]; UILabel *label = (UILabel *)[cell viewWithTag:kLabelTag]; UITextField *textField = nil; for (UIView *oneView in cell.contentView.subviews) { if ([oneView isMemberOfClass:[UITextField class]]) textField = (UITextField *)oneView; } label.text = [bottomCellLabels objectAtIndex:row]; NSNumber *rowAsNum = [[NSNumber alloc] initWithInt:row]; switch (row) { case 0: if ([[tempValues allKeys] containsObject:rowAsNum]) textField.text = [tempValues objectForKey:rowAsNum]; else textField.text = automobile.vinNumber; break; case 1: if ([[tempValues allKeys] containsObject:rowAsNum]) textField.text = [tempValues objectForKey:rowAsNum]; else textField.text = automobile.policyNumber; break; case 2: if ([[tempValues allKeys] containsObject:rowAsNum]) textField.text = [tempValues objectForKey:rowAsNum]; else textField.text = automobile.licensePlate; break; default: break; } if (textFieldBeingEdited == textField) { textFieldBeingEdited = nil; } textField.tag = row; [rowAsNum release]; break; } default: break; } return cell; } Now remember that the first section is working fine and the kode for that method is this: -(IBAction)topTextFieldDone:(id)sender { UITableViewCell *cell = (UITableViewCell *)[[sender superview] superview]; UITableView *table = (UITableView *)[cell superview]; NSIndexPath *textFieldIndexPath = [table indexPathForCell:cell]; NSUInteger row = [textFieldIndexPath row]; row++; if (row > kNumOfEditableRows) row = 0; NSUInteger newIndex[] = {0, row}; NSIndexPath *newPath = [[NSIndexPath alloc] initWithIndexes:newIndex length:2]; UITableViewCell *nextCell = [self.tableView cellForRowAtIndexPath:newPath]; UITextField *nextField = nil; for (UIView *oneView in nextCell.contentView.subviews) { if ([oneView isMemberOfClass:[UITextField class]]) nextField = (UITextField *)oneView; } [nextField becomeFirstResponder]; } It was my idea to just create a second method (secondSectionTextFieldDone:) like this -(IBAction)bottomTextFieldDone:(id)sender { UITableViewCell *cell = (UITableViewCell *)[[sender superview] superview]; UITableView *table = (UITableView *)[cell superview]; NSIndexPath *textFieldIndexPath = [table indexPathForCell:cell]; NSUInteger row = [textFieldIndexPath row]; row++; if (row > 3) row = 0; NSUInteger newIndex[] = {0, row}; NSIndexPath *newPath = [[NSIndexPath alloc] initWithIndexes:newIndex length:2]; UITableViewCell *nextCell = [self.tableView cellForRowAtIndexPath:newPath]; UITextField *nextField = nil; NSString *string = [NSString stringWithFormat:@"AutoEditCellID"]; for (UIView *oneView in nextCell.contentView.subviews) { NSLog(@"%@", nextCell.reuseIdentifier); /* DEBUG LOG */ if ([oneView isMemberOfClass:[UITextField class]] && (nextCell.reuseIdentifier == string)) nextField = (UITextField *)oneView; } [nextField becomeFirstResponder]; } but the result does not solve the issue. so my question is, how can i get the cursor to jump to the next textfield in the section that it is in, If there is one, and if not, then send a message "resignFirstResponder" so that, the keyboard goes away.

    Read the article

  • How to populate a core data store programmatically?

    - by jdmuys
    I have ran out of hairs to pull with a crash in this routine that populates a core data store from a 9000+ line plist file. The crash happened at the very end of the routine inside the call to [managedObjectContext save:&error]. While if I save after every object insertion, the crash doesn't happen. Of course, saving after every object insertion totally kills the performance (from less than a second to many minutes). I modified my code so that it saves every K insertions, and the crash happens as soon as K = 2. The crash is an out-of-bound exception for an NSArray: Serious application error. Exception was caught during Core Data change processing: *** -[NSCFArray objectAtIndex:]: index (1) beyond bounds (1) with userInfo (null) Also maybe relevant, when the exception happen, my fetch result controller controllerDidChangeContent: delegate routine is in the call stack. It simply calls my table view endUpdate routine. I am now running out of ideas. How am I supposed to populate a core data store with a table view? Here is the call stack: #0 0x901ca4e6 in objc_exception_throw #1 0x01d86c3b in +[NSException raise:format:arguments:] #2 0x01d86b9a in +[NSException raise:format:] #3 0x00072cb9 in _NSArrayRaiseBoundException #4 0x00010217 in -[NSCFArray objectAtIndex:] #5 0x002eaaa7 in -[UITableView(_UITableViewPrivate) _endCellAnimationsWithContext:] #6 0x002def02 in -[UITableView endUpdates] #7 0x00004863 in -[AirportViewController controllerDidChangeContent:] at AirportViewController.m:463 #8 0x01c43be1 in -[NSFetchedResultsController(PrivateMethods) _managedObjectContextDidChange:] #9 0x0001462a in _nsnote_callback #10 0x01d31005 in _CFXNotificationPostNotification #11 0x00011ee0 in -[NSNotificationCenter postNotificationName:object:userInfo:] #12 0x01ba417d in -[NSManagedObjectContext(_NSInternalNotificationHandling) _postObjectsDidChangeNotificationWithUserInfo:] #13 0x01c03763 in -[NSManagedObjectContext(_NSInternalChangeProcessing) _createAndPostChangeNotification:withDeletions:withUpdates:withRefreshes:] #14 0x01b885ea in -[NSManagedObjectContext(_NSInternalChangeProcessing) _processRecentChanges:] #15 0x01bbe728 in -[NSManagedObjectContext save:] #16 0x000039ea in -[AirportViewController populateAirports] at AirportViewController.m:112 Here is the code to the routine. I apologize because a number of lines are probably irrelevant, but I'd rather err on that side. The crash happens the very first time it calls [managedObjectContext save:&error]: - (void) populateAirports { NSBundle *meBundle = [NSBundle mainBundle]; NSString *dbPath = [meBundle pathForResource:@"DuckAirportsBin" ofType:@"plist"]; NSArray *initialAirports = [[NSArray alloc] initWithContentsOfFile:dbPath]; //********************************************************************************* // get existing countries NSMutableDictionary *countries = [[NSMutableDictionary alloc] initWithCapacity:200]; NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Country" inManagedObjectContext:managedObjectContext]; [fetchRequest setEntity:entity]; NSError *error = nil; NSArray *values = [managedObjectContext executeFetchRequest:fetchRequest error:&error]; if (!values) { NSLog(@"Unresolved error %@, %@", error, [error userInfo]); abort(); } int numCountries = [values count]; NSLog(@"We have %d countries in store", numCountries); for (Country *aCountry in values) { [countries setObject:aCountry forKey:aCountry.code]; } [fetchRequest release]; //********************************************************************************* // read airports int numAirports = 0; int numUnsavedAirports = 0; #define MAX_UNSAVED_AIRPORTS_BEFORE_SAVE 2 numCountries = 0; for (NSDictionary *anAirport in initialAirports) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSString *countryCode = [anAirport objectForKey:@"country"]; Country *thatCountry = [countries objectForKey:countryCode]; if (!thatCountry) { thatCountry = [NSEntityDescription insertNewObjectForEntityForName:@"Country" inManagedObjectContext:managedObjectContext]; thatCountry.code = countryCode; thatCountry.name = [anAirport objectForKey:@"country_name"]; thatCountry.population = 0; [countries setObject:thatCountry forKey:countryCode]; numCountries++; NSLog(@"Found %dth country %@=%@", numCountries, countryCode, thatCountry.name); } // now that we have the country, we create the airport Airport *newAirport = [NSEntityDescription insertNewObjectForEntityForName:@"Airport" inManagedObjectContext:managedObjectContext]; newAirport.city = [anAirport objectForKey:@"city"]; newAirport.code = [anAirport objectForKey:@"code"]; newAirport.name = [anAirport objectForKey:@"name"]; newAirport.country_name = [anAirport objectForKey:@"country_name"]; newAirport.latitude = [NSNumber numberWithDouble:[[anAirport objectForKey:@"latitude"] doubleValue]]; newAirport.longitude = [NSNumber numberWithDouble:[[anAirport objectForKey:@"longitude"] doubleValue]]; newAirport.altitude = [NSNumber numberWithDouble:[[anAirport objectForKey:@"altitude"] doubleValue]]; newAirport.country = thatCountry; // [thatCountry addAirportsObject:newAirport]; numAirports++; numUnsavedAirports++; if (numUnsavedAirports >= MAX_UNSAVED_AIRPORTS_BEFORE_SAVE) { if (![managedObjectContext save:&error]) { NSLog(@"Unresolved error %@, %@", error, [error userInfo]); abort(); } numUnsavedAirports = 0; } [pool release]; }

    Read the article

  • iPhone SDK 3.2 UIGestureRecognizer interfering with UIView animations?

    - by Brian Cooley
    Are there known issues with gesture recognizers and the UIView class methods for animation? I am having problems with a sequence of animations on a UIImageView from UIGestureRecognizer callback. If the sequence of animations is started from a standard callback like TouchUpInside, the animation works fine. If it is started via the UILongPressGestureRecognizer, then the first animation jumps to the end and the second animation immediately begins. Here's a sample that illustrates my problem. In the .xib for the project, I have a UIImageView that is connected to the viewToMove IBOutlet. I also have a UIButton connected to the startButton IBOutlet, and I have connected its TouchUpInside action to the startButtonClicked IBAction. The TouchUpInside action works as I want it to, but the longPressGestureRecognizer skips to the end of the first animation after about half a second. When I NSLog the second animation (animateTo200) I can see that it is called twice when a long press starts the animation but only once when the button's TouchUpInside action starts the animation. - (void)viewDidLoad { [super viewDidLoad]; UILongPressGestureRecognizer *longPressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(startButtonClicked)]; NSArray *recognizerArray = [[NSArray alloc] initWithObjects:longPressRecognizer, nil]; [startButton setGestureRecognizers:recognizerArray]; [longPressRecognizer release]; [recognizerArray release]; } -(IBAction)startButtonClicked { if (viewToMove.center.x < 150) { [self animateTo200:@"Right to left" finished:nil context:nil]; } else { [self animateTo100:@"Right to left" finished:nil context:nil]; } } -(void)animateTo100:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context { [UIView beginAnimations:@"Right to left" context:nil]; [UIView setAnimationDuration:4]; [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(animateTo200:finished:context:)]; viewToMove.center = CGPointMake(100.0, 100.0); [UIView commitAnimations]; } -(void)animateTo200:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context { [UIView beginAnimations:@"Left to right" context:nil]; [UIView setAnimationDuration:4]; viewToMove.center = CGPointMake(200.0, 200.0); [UIView commitAnimations]; }

    Read the article

  • Update iPhone UIProgressView during NSURLConnection download.

    - by Scott Pendleton
    I am using this code: NSURLConnection *oConnection=[[NSURLConnection alloc] initWithRequest:oRequest delegate:self]; to download a file, and I want to update a progress bar on a subview that I load. For that, I use this code: - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [oReceivedData appendData:data]; float n = oReceivedData.length; float d = self.iTotalSize; NSNumber *oNum = [NSNumber numberWithFloat:n/d]; self.oDPVC.oProgress.progress = [oNum floatValue]; } The subview is oDPVC, and the progress bar on it is oProgress. Setting the progress property does not update the control. From what I have read on the Web, lots of people want to do this and yet there is not a complete, reliable sample. Also, there is much contradictory advice. Some people think that you don't need a separate thread. Some say you need a background thread for the progress update. Some say no, do other things in the background and update the progress on the main thread. I've tried all the advice, and none of it works for me. One more thing, maybe this is a clue. I use this code to load the subview during applicationDidFinishLaunching: self.oDPVC = [[DownloadProgressViewController alloc] initWithNibName:@"DownloadProgressViewController" bundle:nil]; [window addSubview:self.oDPVC.view]; In the XIB file (which I have examined in both Interface Builder and in a text editor) the progress bar is 280 pixels wide. But when the view opens, it has somehow been adjusted to maybe half that width. Also, the background image of the view is default.png. Instead of appearing right on top of the default image, it is shoved up about 10 pixels, leaving a white bar across the bottom of the screen. Maybe that's a separate issue, maybe not.

    Read the article

  • How do you clean Core Data generated models and code from a project?

    - by Hazmit
    I'm having an extremely annoying problem with Core Data in the iPhone SDK. I would say in general Core Data for the most part appears easy to use and nice to implement. I have a sqlite database that is being used as a read only reference to pull data elements out for an iPhone app. It would seem there are really mysterious issues relating to what seems to be migration of the database to the most recent versions of my schema. Why can't you just clean out your stored objects and models and let a project redo all of it when you compile next? You would think if you setup a stored object model there would be a way to just reset it and recompile. I've tried what feels like a thousand 'tips' that have been the results of hours of google searches and documentation prowling to figure out how to do this. My most recent error during compile time is below. 2010-04-07 18:23:51.891 PE[1962:207] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Can't merge models with two different entities named 'PElement'' All of this code has been working in the simulator and is only causing me troubles now because I made a change to the schema. I also have the database options for automatically migrating set as below. NSMutableDictionary *optionsDictionary = [NSMutableDictionary dictionary]; [optionsDictionary setObject:[NSNumber numberWithBool:YES] forKey:NSMigratePersistentStoresAutomaticallyOption]; [optionsDictionary setObject:[NSNumber numberWithBool:YES] forKey:NSInferMappingModelAutomaticallyOption];

    Read the article

  • Can get coordinates from iPhone simulator, but can't get coordinates from iPhone device

    - by iPhoneARguy
    Hi everyone, I've run into something of a mysterious bug (to me). I have some code to pick out the user's current location on the iPhone SDK. It works fine on the iPhone simulator, but when I try to run it on the actual device, I get a weird error. Here is the code (I am using ASIFormDataRequest to create a POST request): ASIFormDataRequest * request = [ASIFormDataRequest requestWithURL:url]; [request setPostValue:@"testauthor" forKey:@"author"]; [request setPostValue:[[NSNumber numberWithDouble:datum.location.coordinate.latitude] stringValue] forKey:@"latitude"]; NSLog(@"%f", datum.location.coordinate.latitude); NSLog(@"%f", datum.location.coordinate.longitude); [request setPostValue:[[NSNumber numberWithDouble:datum.location.coordinate.longitude] stringValue] forKey:@"longitude"]; [request setPostValue:datum.comment forKey:@"comment"]; On the simulator, NSLog does log both the latitude and longitude, but on the iPhone, it does not. Even stranger, when I go through with the debugger on the device, I try "po datum.location", I get <+###, -###> +/- 223.10m (speed 0.00 mps / course -1.00) @ 2010-05-02 22:18:37 -0400 (### replaced by my location) but when I do "(gdb) po datum.location.coordinate" I get: There is no member named coordinate. Do you guys have any idea why this might happen? Thanks in advance for your help!

    Read the article

  • Cocoa NSStream works with SSL, with socks5, but not at the same time

    - by Evan D
    Upon connecting (to an FTP, at first without SSL) I run: NSArray *objects = [NSArray arrayWithObjects:@"proxy.ip", [NSNumber numberWithInt:1080], NSStreamSOCKSProxyVersion5, @"user", @"pass", nil]; NSArray *keys = [NSArray arrayWithObjects:NSStreamSOCKSProxyHostKey, NSStreamSOCKSProxyPortKey, NSStreamSOCKSProxyVersionKey, NSStreamSOCKSProxyUserKey, NSStreamSOCKSProxyPasswordKey, nil]; NSDictionary *proxyDictionary = [NSDictionary dictionaryWithObjects:objects forKeys:keys]; [iStream retain]; [iStream setDelegate:self]; [iStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; [iStream setProperty:proxyDictionary forKey:NSStreamSOCKSProxyConfigurationKey]; [iStream open]; same for iStream. This allows me to connect succesfully through a socks5 proxy. If I continue without setProperty:proxyDictionary... (socks5 disabled) I would tell the server to switch to SSL, and then successfully apply these settings to the in/output streams, thus giving me a SSL connection: NSMutableDictionary *settings = [NSMutableDictionary dictionaryWithCapacity:1]; [settings setObject:(NSString *)NSStreamSocketSecurityLevelTLSv1 forKey:(NSString *)kCFStreamSSLLevel]; // to allow selfsigned certificates: [settings setObject:[NSNumber numberWithBool:YES] forKey:(NSString *)kCFStreamSSLAllowsAnyRoot]; [iStream retain]; [iStream setDelegate:self]; [iStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; CFReadStreamSetProperty((CFReadStreamRef)iStream, kCFStreamPropertySSLSettings, (CFTypeRef)settings); [iStream setProperty:NSStreamSocketSecurityLevelTLSv1 forKey:NSStreamSocketSecurityLevelKey]; same for oStream. All of which works fine if I disable socks5. If I turn it on (line 7 in the first snippit) I lose contact when applying the SSL settings. If I had to guess, I'd think it's losing some properties when applying (ssl) "settings"? Please help :) Evan

    Read the article

  • Struggling with currency in Cocoa.

    - by Meltemi
    I'm trying to do something I'd think would be fairly simple: Let a user input a dollar amount, store that amount in an NSNumber (NSDecimalNumber?), then display that amount formatted as currency again at some later time. My trouble is not so much with the setNumberStyle:NSNumberFormatterCurrencyStyle and displaying floats as currency. The trouble is more with how said numberFormatter works with this UITextField. I can find few examples. This thread from November and this one give me some ideas but leaves me with more questions. I am using the UIKeyboardTypeNumberPad keyboard and understand that I should probably show $0.00 (or whatever local currency format is) in the field upon display then as a user enters numerals to shift the decimal place along: Begin with display $0.00 Tap 2 key: display $0.02 Tap 5 key: display $0.25 Tap 4 key: display $2.54 Tap 3 key: display $25.43 Then [numberFormatter numberFromString:textField.text] should give me a value I can store in my NSNumber variable. Sadly I'm still struggling: Is this really the best/easiest way? If so then maybe someone can help me with the implementation? I feel UITextField may need a delegate responding to every keypress but not sure what, where and how to implement it?! Any sample code? I'd greatly appreciate it! I've searched high and low... Edit1: So I'm looking into NSFormatter's stringForObjectValue: and the closest thing I can find to what benzado recommends: UITextViewTextDidChangeNotification. Having really tough time finding sample code on either of them...so let me know if you know where to look?

    Read the article

  • Custom Keyboard (iPhone), UIKeyboardDidShowNotification and UITableViewController

    - by Pascal
    On an iPhone App, I've got a custom keyboard which works like the standard keyboard; it appears if a custom textfield becomes first responder and hides if the field resigns first responder. I'm also posting the Generic UIKeyboardWillShowNotification, UIKeyboardDidShowNotification and their hiding counterparts, like follows: NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithCapacity:5]; [userInfo setObject:[NSValue valueWithCGPoint:self.center] forKey:UIKeyboardCenterBeginUserInfoKey]; [userInfo setObject:[NSValue valueWithCGPoint:shownCenter] forKey:UIKeyboardCenterEndUserInfoKey]; [userInfo setObject:[NSValue valueWithCGRect:self.bounds] forKey:UIKeyboardBoundsUserInfoKey]; [userInfo setObject:[NSNumber numberWithInt:UIViewAnimationCurveEaseOut] forKey:UIKeyboardAnimationCurveUserInfoKey]; [userInfo setObject:[NSNumber numberWithDouble:thisAnimDuration] forKey:UIKeyboardAnimationDurationUserInfoKey]; [[NSNotificationCenter defaultCenter] postNotificationName:UIKeyboardWillShowNotification object:nil userInfo:userInfo]; This code is working and I use it in UIViewController subclasses. Now since iPhone OS 3.0, UITableViewController automatically resizes its tableView when the system keyboards show and hide. I'm only now compiling against 3.0 and I thought that the controller should also resize the table if my custom keyboard appears, since I'm posting the same notification. However it doesn't. The table view controller is set as the delegate of the input fields. Does anyone have an idea why this might be the case? Has anyone implemented something similar successfully? I have standard input fields along the custom ones, so if the user changes the fields the standard keyboard hides and the custom one shows. It would be beneficial if the tableView didn't resize to full height and I didn't have to resize it back with a custom method.

    Read the article

  • Can a function return an object? Objective-C and NSMutableArray

    - by seaworthy
    I have an NSMutableArray. It's members eventually become members of an array instance in a class. I want to put the instantiantion of NSMutable into a function and to return an array object. If I can do this, I can make some of my code easier to read. Is this possible? Here is what I am trying to figure out. //Definition: > function Objects (float a, float b) { > NSMutableArray *array = [[NSMutableArray alloc] init]; > [array addObject:[NSNumber numberWithFloat:a]]; > [array addObject:[NSNumber numberWithFloat:b]]; > //[release array]; ???????? return array; > } //Declaration: Math *operator = [[Math alloc] init]; [operator findSum:Objects(20.0,30.0)]; My code compiles if I instantiate NSMutableArray right before I send the message to the receiver. I know I can have an array argument along with the method. What I have problem seeing is how to use a function and to replace the argument with a function call. Any help is appreciated. I am interested in the concept not in suggestions to replace the findSum method.

    Read the article

  • How to switch from Core Data automatic lightweight migration to manual?

    - by Jaanus
    My situation is similar to this question. I am using lightweight migration with the following code, fairly vanilla from Apple docs and other SO threads. It runs upon app startup when initializing the Core Data stack. NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil]; NSError *error = nil; NSString *storeType = nil; if (USE_SQLITE) { // app configuration storeType = NSSQLiteStoreType; } else { storeType = NSBinaryStoreType; } persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]]; // the following line sometimes crashes on app startup if (![persistentStoreCoordinator addPersistentStoreWithType:storeType configuration:nil URL:[self persistentStoreURL] options:options error:&error]) { // handle the error } For some users, especially with slower devices, I have crashes confirmed by logs at the indicated line. I understand that a fix is to switch this to manual mapping and migration. What is the recipe to do that? The long way for me would be to go through all Apple docs, but I don't recall there being good examples and tutorials specifically for schema migration.

    Read the article

  • Is this a correct porting of java.util.Random in objectiveC

    - by dipu
    I have ported the code inside java.util.Random class in objectivec. I want to have an identical random number generator so that it synchs with the server app running on java. Now is this a safe porting and if not is there a way to mimic AtomicLong as it is found in java? Please see my code below. static long long multiplier = 0x5DEECE66DL; static long addend = 0xBL; static long long mask = (0x1000000000000001L << 48) - 1; -(void) initWithSeed:(long long) seed1 { [self setRandomSeed: 0L];// = new AtomicLong(0L); [self setSeed: seed1]; } -(int) next:(int)bits { long long oldseed, nextseed; long long seed1 = [self.randomSeed longLongValue]; //AtomicLong //do { oldseed = seed1; nextseed = (oldseed * multiplier + addend) & mask; //} while (!seed.compareAndSet(oldseed, nextseed)); [self setRandomSeed: [NSNumber numberWithLongLong:nextseed]]; ///int ret = (int)(nextseed >>> (48 - bits)); int ret = (unsigned int)(nextseed >> (48 - bits)); return ret; } -(void) setSeed:(long long) seed1 { seed1 = (seed1 ^ multiplier) & mask; [self setRandomSeed: [NSNumber numberWithLongLong:seed1]]; }

    Read the article

  • AdressBook Crash, only with some contacts!

    - by Zebs
    My app crashes, it is a problem that arises from the AddressBook API, it only happens with some contacts. Here is the log: Exception Type: EXC_BREAKPOINT (SIGTRAP) Exception Codes: 0x00000102, 0x316ebd38 Crashed Thread: 0 Thread 0 Crashed: 0 CoreFoundation 0x00001cfe CFRetain + 90 1 AddressBook 0x00004b2c ABCMultiValueCopyValueAtIndex + 28 2 AddressBook 0x0001066a ABMultiValueCopyValueAtIndex + 2 3 Call Monitor 0x00003824 -[CallAppDelegate peoplePickerNavigationController:shouldContinueAfterSelectingPerson:property:identifier:] (AppDelegate.m:408) 4 AddressBookUI 0x00032cfc -[ABPeoplePickerNavigationController personViewController:shouldPerformDefaultActionForPerson:property:identifier:withMemberCell:] + 152 5 AddressBookUI 0x0003b8ce -[ABPersonViewControllerHelper personTableViewDataSource:selectedPropertyAtIndex:inPropertyGroup:withMemberCell:forEditing:] + 222 6 AddressBookUI 0x0004a17c -[ABPersonTableViewDataSource valueAtIndex:selectedForPropertyGroup:withMemberCell:forEditing:] + 40 7 AddressBookUI 0x00048c00 -[ABPersonTableViewDataSource tableView:didSelectRowAtIndexPath:] + 316 8 UIKit 0x00091f40 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 656 9 UIKit 0x0009db40 -[UITableView _userSelectRowAtIndexPath:] + 124 10 Foundation 0x00086c86 __NSFireDelayedPerform + 362 11 CoreFoundation 0x00071a54 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 8 12 CoreFoundation 0x00073ede __CFRunLoopDoTimer + 854 13 CoreFoundation 0x0007485e __CFRunLoopRun + 1082 14 CoreFoundation 0x0001d8e4 CFRunLoopRunSpecific + 224 15 CoreFoundation 0x0001d7ec CFRunLoopRunInMode + 52 16 GraphicsServices 0x000036e8 GSEventRunModal + 108 17 GraphicsServices 0x00003794 GSEventRun + 56 18 UIKit 0x000062a0 -[UIApplication _run] + 396 19 UIKit 0x00004e10 UIApplicationMain + 664 20 Call Monitor 0x000028e8 main (main.m:14) 21 Call Monitor 0x000028b8 start + 32 This is driving me crazy, as it only happens with an isolated number of contacts. Any help would be greatly appreciated. Here is the code that was requested, thank you very very much for your help: (It is an extract from the method where I think the error happens) The weird thing is that it only happens with certain contacts, and deleting the contact, then creating a new one solves the problem... - (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier NSString* firstName = (NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty); NSString* lastName = (NSString *)ABRecordCopyValue(person, kABPersonLastNameProperty); NSNumber* record = [NSNumber numberWithInt:ABRecordGetRecordID(person)]; if(lastName!=nil){ name=[NSString stringWithFormat:@"%@ %@",firstName,lastName]; } else { name=firstName; } ABMultiValueRef phone = ABRecordCopyValue(person, property); NSString *value =(NSString *)ABMultiValueCopyValueAtIndex(phone, identifier); NSString *label =(NSString *)ABMultiValueCopyLabelAtIndex(phone, identifier); NSMutableArray *tempArray=[[NSMutableArray alloc] initWithArray:[[NSUserDefaults standardUserDefaults] objectForKey:@"MainArray"]]; NSDictionary *stringDictionary = [NSDictionary dictionaryWithObjectsAndKeys:name, kLabelKey, value, kNumberKey,label, kNumberLabelKey,record, kReferenceKey, nil]; [tempArray addObject:stringDictionary]; NSArray *mainArray = [NSArray arrayWithArray:tempArray]; [[NSUserDefaults standardUserDefaults] setObject:mainArray forKey:@"MainArray"];

    Read the article

  • Implementation of "Automatic Lightweight Migration" for Core Data (iPhone)

    - by RickiG
    Hi I would like to make my app able to do an automatic lightweight migration when I add new attributes to my core data model. In the guide from Apple this is the only info on the subject I could find: Automatic Lightweight Migration To request automatic lightweight migration, you set appropriate flags in the options dictionary you pass in addPersistentStoreWithType:configuration:URL:options:error:. You need to set values corresponding to both the NSMigratePersistentStoresAutomaticallyOption and the NSInferMappingModelAutomaticallyOption keys to YES: NSError *error; NSURL *storeURL = <#The URL of a persistent store#>; NSPersistentStoreCoordinator *psc = <#The coordinator#>; NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil]; if (![psc addPersistentStoreWithType:<#Store type#> configuration:<#Configuration or nil#> URL:storeURL options:options error:&error]) { // Handle the error. } My NSPersistentStoreCoordinator is initialized in this way: - (NSPersistentStoreCoordinator *)persistentStoreCoordinator { if (persistentStoreCoordinator != nil) { return persistentStoreCoordinator; } NSURL *storeUrl = [NSURL fileURLWithPath: [[self applicationDocumentsDirectory] stringByAppendingPathComponent: @"FC.sqlite"]]; NSError *error = nil; persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]]; if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:nil error:&error]) { NSLog(@"Unresolved error %@, %@", error, [error userInfo]); abort(); } return persistentStoreCoordinator; } I am having trouble seeing where and how I should add the Apple code to get the Automatic Lightweight Migration working?

    Read the article

  • NSMutableArray Problem - iPhone

    - by David Schiefer
    Hi, I'm trying to get a UITableView to read it's data from a file. I've attempted it like this: NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *fullFileName = [NSString stringWithFormat:@"%@/entries.plist", documentsDirectory]; self.dataForTable = [[NSMutableArray alloc] initWithContentsOfFile:fullFileName]; This compiles fine, but when saving something to the file in the following snippet, the file is not saved nor anything is written to the array: NSMutableDictionary*userDictionary; userDictionary = [[NSMutableDictionary alloc] init]; [userDictionary setObject:name.text forKey:@"name"]; [userDictionary setObject:email.text forKey:@"email"]; [userDictionary setObject:serial.text forKey:@"serial"]; [userDictionary setObject:notes.text forKey:@"notes"]; [userDictionary setObject:[NSNumber numberWithInt:[licenseType selectedRowInComponent:0]] forKey:@"license_type"]; [userDictionary setObject:[date date] forKey:@"date"]; [userDictionary setObject:[NSNumber numberWithBool:[paymentSwitch isOn]] forKey:@"payment"]; NSString*dirToSaveTo = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]; NSString*fileName = [NSString stringWithFormat:@"%@.plist",name.text]; NSString*saveName = [dirToSaveTo stringByAppendingPathComponent:fileName]; [userDictionary writeToFile:saveName atomically:NO]; NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *fullFileName = [NSString stringWithFormat:@"%@/entries.plist", documentsDirectory]; [self.dataForTable addObject:name.text]; NSLog(@"%@",self.dataForTable); [self.dataForTable writeToFile:fullFileName atomically:YES]; The NSLog just returns (null). The *plist file is never written. What am I doing wrong?

    Read the article

  • Why is there no autorelease pool when I do performSelectorInBackground: ?

    - by Thanks
    I am calling a method that goes in a background thread: [self performSelectorInBackground:@selector(loadViewControllerWithIndex:) withObject:[NSNumber numberWithInt:viewControllerIndex]]; then, I have this method implementation that gets called by the selector: - (void) loadViewControllerWithIndex:(NSNumber *)indexNumberObj { NSAutoreleasePool *arPool = [[NSAutoreleasePool alloc] init]; NSInteger vcIndex = [indexNumberObj intValue]; Class c; UIViewController *controller = [viewControllers objectAtIndex:vcIndex]; switch (vcIndex) { case 0: c = [MyFirstViewController class]; break; case 1: c = [MySecondViewController class]; break; default: NSLog(@"unknown index for loading view controller: %d", vcIndex); // error break; } if ((NSNull *)controller == [NSNull null]) { controller = [[c alloc] initWithNib]; [viewControllers replaceObjectAtIndex:vcIndex withObject:controller]; [controller release]; } if (controller.view.superview == nil) { UIView *placeholderView = [viewControllerPlaceholderViews objectAtIndex:vcIndex]; [placeholderView addSubview:controller.view]; } [arPool release]; } Althoug I do create an autorelease pool there for that thread, I always get this error: 2009-05-30 12:03:09.910 Demo[1827:3f03] *** _NSAutoreleaseNoPool(): Object 0x523e50 of class NSCFNumber autoreleased with no pool in place - just leaking Stack: (0x95c83f0f 0x95b90442 0x28d3 0x2d42 0x95b96e0d 0x95b969b4 0x93a00155 0x93a00012) If I take away the autorelease pool, I get a whole bunch of messages like these. I also tried to create an autorelease pool around the call of the performSelectorInBackground:, but that doesn't help. I suspect the parameter, but I don't know why the compiler complains about an NSCFNumber. Am I missing something? My Instance variables are all "nonatomic". Can that be a problem? UPDATE: I may also suspect that some variable has been added to an autorelease pool of the main thread (maybe an ivar), and now it trys to release that one inside the wrong autorelease pool? If so, how could I fix that? (damn, this threading stuff is complex ;) )

    Read the article

  • Objective C loop logic

    - by Graham
    Hi guys, I'm really new to programming in Obj-C, my background is in labview which is a graphical programming language, I've worked with Visual Basic some and HTML/CSS a fair amount as well. I'm trying to figure out the logic to create an array of data for the pattern below. I need the pattern later to extract data from another 2 arrays in a specific order. I can do it by referencing a = 1, b = 2, c = 3 etc and then creating the array with a, b, c but I want to use a loop so that I don't have 8 references above the array. These references will be used to generate another generation of data so unless I can get help figuring out the logic I'll actually end up with 72 references above the array. // This is the first one which gives the pattern 0 0 0 0 (etc) // 1 1 1 1 // 2 2 2 2 NSMutableArray * expSecondRef_one = [NSMutableArray array]; int a1 = 0; while (a1 < 9) { int a2 = 0; while (a2 < 8) { NSNumber * a3 = [NSNumber numberWithInt:a1]; [expSecondRef_one addObject:a3]; a2++; } a1++; } // This is the second one which I'm stumbling over, I am looking for the pattern 1 2 3 4 5 6 7 8 // 0 2 3 4 5 6 7 8 // 0 1 3 4 5 6 7 8 // 0 1 2 4 5 6 7 8 // etc to -> // 0 1 2 3 4 5 6 7 If you run it in a line every 9th number is -1 but I don't know how to do that over a pattern of 8. Thanks in advance! Graham

    Read the article

  • compiler directive defensive programming for adding ints to nsmuatablearray FMDB/EGODB

    - by johndpope
    I would like to throw a warning message when users try to add an int to an nsmutablearray basically any insert statement that includes values that are not nsstring / nsnumber cause run time crashes. It's exactly the same crash you get when you type %@ instead of %d NSLog(int); The crash is ok, but I want to throw a friendly 'FATAL' message to user. so far I have this try catch with isKindOfClass NSObject but ints are slipping through. #define FATAL_MSG "FATAL: object is not an NSObject subclass. Are you using int? use [NSNumber numberWithInt:1] \n" #define VAToArray(firstarg) ({\ NSMutableArray* valistArray = [NSMutableArray array];\ id obj = nil;\ va_list arguments;\ va_start(arguments, sql);\ @try { \ while ((obj = va_arg(arguments, id))) {\ if([obj isKindOfClass:[NSObject class]]) [valistArray addObject:obj];\ else printf(FATAL_MSG); \ }\ } \ @catch(NSException *exception){ \ printf(FATAL_MSG); \ } \ va_end(arguments);\ valistArray;\ }) - (void)test:(NSString*)sql,... { NSLog(@"VAToArray :%@",VAToArray(sql)); } // then call this [self test:@"str",@"test",nil]; when I call this [self test:@"str",2,nil]; throw the error message.

    Read the article

  • [Cocoa] Placing an NSTimer in a separate thread

    - by ndg
    I'm trying to setup an NSTimer in a separate thread so that it continues to fire when users interact with the UI of my application. This seems to work, but Leaks reports a number of issues - and I believe I've narrowed it down to my timer code. Currently what's happening is that updateTimer tries to access an NSArrayController (timersController) which is bound to an NSTableView in my applications interface. From there, I grab the first selected row and alter its timeSpent column. From reading around, I believe what I should be trying to do is execute the updateTimer function on the main thread, rather than in my timers secondary thread. I'm posting here in the hopes that someone with more experience can tell me if that's the only thing I'm doing wrong. Having read Apple's documentation on Threading, I've found it an overwhelmingly large subject area. NSThread *timerThread = [[[NSThread alloc] initWithTarget:self selector:@selector(startTimerThread) object:nil] autorelease]; [timerThread start]; -(void)startTimerThread { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; activeTimer = [[NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(updateTimer:) userInfo:nil repeats:YES] retain]; [runLoop run]; [pool release]; } -(void)updateTimer:(NSTimer *)timer { NSArray *selectedTimers = [timersController selectedObjects]; id selectedTimer = [selectedTimers objectAtIndex:0]; NSNumber *currentTimeSpent = [selectedTimer timeSpent]; [selectedTimer setValue:[NSNumber numberWithInt:[currentTimeSpent intValue]+1] forKey:@"timeSpent"]; } -(void)stopTimer { [activeTimer invalidate]; [activeTimer release]; }

    Read the article

  • Problem with UITextView

    - by user367039
    I have a strange problem with trying to pass a string from one viewcontroller to another view controller if the string originates from a UITextview instead of UITextfield. Both UITextview.text and UITextfield.text are of type NSString. The following code takes either Textfield.text or Textview.text depending on the fieldType and puts it into a string called aString. NSString *aString = [[NSString alloc] init]; if (fieldType == 3) { aString = textView.text; } else { aString = textField.text; } When I examine aString on either cases, I can see that it has successfully assigned the text into aString. I then pass the string to the other view controller using this code. [delegate updateSite:aString :editedFieldKey :fieldType]; [self.navigationController popViewControllerAnimated:YES]; This works fine if aString originated from textfield.text but nothing happens except the view controller is popped if aString was from textview.text This is the code that takes aString and does stuff with it, however it doesn't even execute the first line of code "NSLog(@"Returned object: %@, field type:%@", aString,editedFieldKey);" if aString was from textview.text Any help will be appreciated. -(void)updateSite:(NSString *)aString :(NSString *)editedFieldKey :(int)fieldType { NSLog(@"Returned object: %@, field type:%@", aString,editedFieldKey); switch (fieldType) { case 0: //string [aDiveSite setValue:aString forKey:editedFieldKey] ; NSLog(@"String set %@",[aDiveSite valueForKey:editedFieldKey] ); break; case 1: //int [aDiveSite setValue:[NSNumber numberWithInt:aString.intValue] forKey:editedFieldKey]; NSLog(@"Integer set"); break; case 2: //float NSLog(@"Saving floating value"); [aDiveSite setValue:[NSNumber numberWithFloat:aString.floatValue] forKey:editedFieldKey]; NSLog(@"Float set"); break; case 3: //Text view [aDiveSite setValue:aString forKey:editedFieldKey]; NSLog(@"Textview text saved"); default: break; } [self.tableView reloadData]; }

    Read the article

  • UIImageView Fade-In Dissapears

    - by Winder
    I have this code which should create a splash image with either no animation or a fade in, then call code to dismiss the image out after a delay. The SplashViewAnimationNone works fine and creates the full screen image, but the Fade code fades the image in but then immediately disappears. - (void)startSplash { [[[[UIApplication sharedApplication] windows] objectAtIndex:0] addSubview:self]; splashImage = [[UIImageView alloc] initWithImage:self.image]; if (self.animationIn == SplashViewAnimationNone) { [self addSubview:splashImage]; } else if (self.animationIn == SplashViewAnimationFade) { [self addSubview:splashImage]; CABasicAnimation *animSplash = [CABasicAnimation animationWithKeyPath:@"opacity"]; animSplash.duration = self.animationDelay; animSplash.removedOnCompletion = NO; animSplash.fillMode = kCAFillModeForwards; animSplash.fromValue = [NSNumber numberWithFloat:0.0]; animSplash.toValue = [NSNumber numberWithFloat:1.0]; animSplash.delegate = self; [self.layer addAnimation:animSplash forKey:@"animateOpacity"]; } // Dismiss after delay. [self performSelector:@selector(dismissSplash) withObject:self afterDelay:self.delay]; }

    Read the article

  • NSInvocation object not getting allocated iphone sdk

    - by neha
    Hi all, I'm doing NSString *_type_ = @"report"; NSNumber *_id_ = [NSNumber numberWithInt:report.reportId]; NSDictionary *paramObj = [NSDictionary dictionaryWithObjectsAndKeys: _id_, @"bla1", _type_, @"bla2",nil]; _operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(initParsersetId:) object:paramObj]; But my _operation object is nil even after processing this line. The selector here is actually a function I'm writing which is like: -(void)initParsersetId:(NSInteger)_id_ type:(NSString *)_type_ { NSString *urlStr = [NSString stringWithFormat:@"apimediadetails?id=624&type=report"]; NSString *finalURLstr = [urlStr stringByAppendingString:URL]; NSURL *url = [[NSURL alloc] initWithString:finalURLstr]; NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithContentsOfURL:url]; //Initialize the delegate. DetailedViewObject *parser = [[DetailedViewObject alloc] initDetailedViewObject]; //Set delegate [xmlParser setDelegate:parser]; //Start parsing the XML file. BOOL success = [xmlParser parse]; if(success) NSLog(@"No Errors"); else NSLog(@"Error Error Error!!!"); } Can anybody please point out wheather where I'm going wrong. Thanx in advance.

    Read the article

  • Memory management of objects returned by methods (iOS / Objective-C)

    - by iOSNewb
    I am learning Objective-C and iOS programming through the terrific iTunesU course posted by Stanford (http://www.stanford.edu/class/cs193p/cgi-bin/drupal/) Assignment 2 is to create a calculator with variable buttons. The chain of commands (e.g. 3+x-y) is stored in a NSMutableArray as "anExpression", and then we sub in random values for x and y based on an NSDictionary to get a solution. This part of the assignment is tripping me up: The final two [methods] “convert” anExpression to/from a property list: + (id)propertyListForExpression:(id)anExpression; + (id)expressionForPropertyList:(id)propertyList; You’ll remember from lecture that a property list is just any combination of NSArray, NSDictionary, NSString, NSNumber, etc., so why do we even need this method since anExpression is already a property list? (Since the expressions we build are NSMutableArrays that contain only NSString and NSNumber objects, they are, indeed, already property lists.) Well, because the caller of our API has no idea that anExpression is a property list. That’s an internal implementation detail we have chosen not to expose to callers. Even so, you may think, the implementation of these two methods is easy because anExpression is already a property list so we can just return the argument right back, right? Well, yes and no. The memory management on this one is a bit tricky. We’ll leave it up to you to figure out. Give it your best shot. Obviously, I am missing something with respect to memory management because I don't see why I can't just return the passed arguments right back. Thanks in advance for any answers!

    Read the article

  • probelem with NSTimer

    - by zp26
    Hi I have a problem with a NSTimer I recived a "SIGABRT" error and "[NSCFTimer intValue]: unrecognized selector sent to instance " These is my code: -(void)detectionMove:(NSNumber*)arrayIndex{ static BOOL notFind = FALSE; static int countVariable = 0; static int countRilevamenti = 0; notFind = FALSE; for(int i = countVariable+1; i<[[[[sharedController arrayMovement]objectAtIndex:[arrayIndex intValue]] arrayPositionMove]count]; i++){ if(!notFind){ if((actualAccelerometerX+sensibilityMovement) >= [[[[[sharedController arrayMovement]objectAtIndex:[arrayIndex intValue]] arrayPositionMove]objectAtIndex:i]valueX] && (actualAccelerometerX-sensibilityMovement) <= [[[[[sharedController arrayMovement]objectAtIndex:[arrayIndex intValue]] arrayPositionMove]objectAtIndex:i]valueX] && (actualAccelerometerY+sensibilityMovement) >= [[[[[sharedController arrayMovement]objectAtIndex:[arrayIndex intValue]] arrayPositionMove]objectAtIndex:i]valueY] && (actualAccelerometerY-sensibilityMovement) <= [[[[[sharedController arrayMovement]objectAtIndex:[arrayIndex intValue]] arrayPositionMove]objectAtIndex:i]valueY] && (actualAccelerometerZ+sensibilityMovement) >= [[[[[sharedController arrayMovement]objectAtIndex:[arrayIndex intValue]] arrayPositionMove]objectAtIndex:i]valueZ] && (actualAccelerometerZ-sensibilityMovement) <= [[[[[sharedController arrayMovement]objectAtIndex:[arrayIndex intValue]] arrayPositionMove]objectAtIndex:i]valueZ]) { countVariable = i; notFind = TRUE; countRilevamenti++; } } } if(!notFind) return; else if(countVariable+1 == [[[[sharedController arrayMovement]objectAtIndex:[arrayIndex intValue]] arrayPositionMove]count]){ if(countRilevamenti + tollerance >= [[[[sharedController arrayMovement]objectAtIndex:[arrayIndex intValue]] arrayPositionMove]count]) movementDetected = [arrayIndex intValue]; else NSLog(@"troppo veloce"); countVariable = 0; notFind = FALSE; countRilevamenti = 0; return; } [NSTimer scheduledTimerWithTimeInterval:timeToCatch target:self selector:@selector(detectionMove:) userInfo:(NSNumber*)arrayIndex repeats:NO]; }

    Read the article

  • Why is the compiler caching my "random" and NULLED variables?

    - by alex gray
    I am confounded by the fact that even using different programs (on the same machine) to run /compile, and after nilling the vaues (before and after) the function.. that NO MATTER WHAT.. I'll keep getting the SAME "random" numbers… each and every time I run it. I swear this is NOT how it's supposed to work.. I'm going to illustrate as simply as is possible… #import <Foundation/Foundation.h> int main(int argc, char *argv[]) { int rPrimitive = 0; rPrimitive = 1 + rand() % 50; NSNumber *rObject = nil; rObject = [NSNumber numberWithInt:rand() % 10]; NSLog(@"%i %@", rPrimitive, rObject); rPrimitive = 0; rObject = nil; NSLog(@"%i %@", rPrimitive, rObject); return 0; } Run it in TextMate: i686-apple-darwin11-llvm-gcc-4.2 8 9 0 (null) Run it in CodeRunner: i686-apple-darwin11-llvm-gcc-4.2 8 9 0 (null) Run it a million times, if you'd like. You can gues what it will always be. Why does this happen? Why oh why is this "how it is"?

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12  | Next Page >