[Solved] How to get index of array element in cell? [closed]

Sorry if I’m understanding your English incorrectly, but I guess this is along the lines of what you want: You can get the indexPath of the row that was selected in a table by implementing tableView:didSelectRowAtIndexPath: in you tableView’s delegate (presumably your tableViewController). An indexPath has two properties you’ll be interested in; section and row. … Read more

[Solved] UITableView crashing on scroll

Bind UITableView properly in XIB. and right following code. – (void)viewDidLoad { [super viewDidLoad]; self.tableView.separatorColor = [UIColor clearColor]; } – (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } – (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 3; } – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @”Cell”; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) … Read more

[Solved] Parse JSON with Objective-C

its because timeslots is under “Sunday, August 10, 2014” this dictionary. Its second layer. First retrieve “Sunday, August 10, 2014” dictionary then you will be able to access timeslot array. Modify your for loop like below for (NSDictionary *oneDay in data) { NSDictionary *dData = [oneDay objectForKey:@”Sunday, August 10, 2014″]; NSDictionary *tslots = [dData objectForKey:@”timeslots”]; … Read more

[Solved] Unrecognized selector sent to instance NSArrayM [closed]

Did you removed UITabBarController also from your .xib file in Interface Builder? Did you removed UITabBarController also from your .xib file in Interface Builder? Check if object – in your case NSDictionary is kind of it’s class and key is not null. For example: – (void)fetchedDataAlerta:(NSData *)responseData { NSError* error; NSLog(@”RESP register %@”, responseData); if(responseData … Read more

[Solved] Identify different iOS devices in coding? [closed]

The way I determine what iOS device I am running on so we can change layout based on the iDevices size such as iPad and iPhone is like. // iPhone 5 (iPhone 4″) #define IS_PHONEPOD5() ([UIScreen mainScreen].bounds.size.height == 568.0f && [UIScreen mainScreen].scale == 2.f && UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) To get iPhone 5 you could also … Read more

[Solved] How to remove common letters in two Strings in iOS SDK? [duplicate]

You can proceed similar as in this answer to your previous question: NSString *string1 = @”optimusprime”; NSString *string2 = @”dejathoras”; // Combine strings: NSString *combined = [string1 stringByAppendingString:string2]; // Now remove duplicate characters: NSMutableString *result = [combined mutableCopy]; [result enumerateSubstringsInRange:NSMakeRange(0, [result length]) options:NSStringEnumerationByComposedCharacterSequences usingBlock:^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop) { // Check if … Read more

[Solved] how to I convert a string with format “YYYY/MM/DD” into NSDate type? [duplicate]

You can convert it to an NSDate using the NSDateFormatter. NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@”yyyy/MM/dd”]; NSdate *date = [dateFormatter dateFromString:@”2012/03/17″]; Be aware that allocating an NSDateFormatter is a pretty heavy task so if you are parsing a lot of dates then allocate it once and keep it around 🙂 solved how to … Read more

[Solved] Adding math symbols in a string [closed]

int a = 10; int b = 20; NSString *c = @”+”; NSString *s = [NSString stringWithFormat:@”%d %@ %d”, a, c, b]; NSExpression *e = [NSExpression expressionWithFormat:s]; int result = [[e expressionValueWithObject:nil context:nil] intValue]; NSLog(@”%d”, result); 4 solved Adding math symbols in a string [closed]

[Solved] Can’t use a string in .m

Add a property for your string in viewController.h outside the interface like this viewController.h { NSString *string; } @property (nonatomic, retain) NSString *string; and synthesize it in viewController.m @synthesize string; So that you can access that string in other files where you imported your viewController.h EDIT: create an object for your viewController.h in file2 and … Read more

[Solved] Two different heights for sectionHeaderView

Your code is wrong try this: – (CGFloat)tableView:(UITableView *)tableView heightForViewForHeaderInSection: (NSIndexPath *)indexPath { if(indexPath.section == 0) // First section { return 300; } else if(indexPath.section == 1) { // Second return 50; } else { // Any other section return 40.0; // Default } } 1 solved Two different heights for sectionHeaderView

[Solved] Why does my app crash when I tap the background?

From the chat with Jack, it appears the culprit of the crash was due to a method: -(void)dismissKeyboard { // —————————————————— // These variables appear to be NSString, so it crashes // —————————————————— [message resignFirstResponder]; [contact1 resignFirstResponder]; [contact2 resignFirstResponder]; [contact3 resignFirstResponder]; } So the solution was to simply change it to: -(void)dismissKeyboard { [self.view endEditing:YES]; … Read more