Skip to main content

Posts

NSRangeException when deleting cell using a different class

I looked through my code and I printed my array I was using and it appears to be fine, yet this error still persists. * Terminating app due to uncaught exception 'NSRangeException', reason: '* -[__NSArrayM removeObjectAtIndex:]: index 1 beyond bounds [0 .. 0]' My guess was that it had something to do with my indexPath but it doesn't make much different how much I change it. -(void)checkboxTapped:(id)sender { [sender setSelected:YES]; [self.textLabel setTextColor:[UIColor grayColor]]; [self.detailTextLabel setTextColor:[UIColor grayColor]]; parent = [[ViewController alloc] init]; UITableView *tableView = parent.tableView; NSMutableArray *array = [[NSMutableArray alloc] initWithArray:parent.array]; [parent release]; NSIndexPath *indexPath = [NSIndexPath indexPathForRow:[array count] inSection:1]; [array removeObjectAtIndex:[indexPath row]]; [db deleteTaskAtIndex:[indexPath row]]; [tableView deleteRowsAtIndex

display UIMenuController on tab on cell

I have uitableview I want to display UIMenuController when I tab on cell such that if the content of the cell is text the menu show edit , send by mail else listen, send by mail adn hide it it if I leaved it or tab away of it, something like right click context menue any idea how to achieve that I did something like that - (BOOL)tableView:(UITableView *)tableView shouldShowMenuForRowAtIndexPath:(NSIndexPath *)indexPath { return YES; } - (BOOL)tableView:(UITableView *)tableView canPerformAction:(SEL)action forRowAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender { return (action == @selector(copy:)); } - (void)tableView:(UITableView *)tableView performAction:(SEL)action forRowAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender { if (action == @selector(copy:)) NSLog(@"in real life, we'd now copy somehow"); } but I need to customize the menu itself, and also implementing those thre methods doesn't show anything Best regards

GPS and draw MapRout in iphone

I have a latitude and longitude that is fixed, so I used that and got the point in mapview with pin. Now I want the current location and draw route, so I think using gps I get the latitude and longitude. Using this location(latitude & longitude) I have to draw a route with my fixed value (latitude & longitude). How is it possible..? Is this is the right way to do it? ?How to draw the route with two point..? I have used the delegate method but it doesn't call, - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { [manager stopUpdatingHeading]; NSLog(@"latitude=%f",newLocation.coordinate.latitude); NSLog(@"longitude=%f",newLocation.coordinate.longitude); }

iOS ARC - weak and strong properties

I'm trying to understand the way ARC works, and as far as I know, I should be doing something wrong here. This is the code I'm using: Interface: @interface ViewController : UIViewController{ } @property (strong, nonatomic) NSString * myString ; @property (weak, nonatomic) NSString * myPointer ; Implementation: - (void)viewDidLoad{ [super viewDidLoad]; self.myString = @"Hello world!" ; // myString is strong self.myPointer = self.myString ; // myPointer var is weak [self performSelector:@selector(makeNilMyValue) withObject:nil afterDelay:1]; [self performSelector:@selector(printValues) withObject:nil afterDelay:2]; } - (void) makeNilMyValue{ self.myString = nil ; } - (void) printValues{ NSLog(@"myString: %@", self.myString) ; NSLog(@"myPointer: %@", self.myPointer) ; } After executing this, I get: 2012-02-26 11:40:41.652 test1[933:207] myString: (null) 2012-02-26 11:40:41.653 test1[933:207] myP

NSFetchRequest for all children of a parent

How do I fetch all child entities of a parent? I have a table populated by a parent entity in Core Data. When the user touches a cell I intend to show another table with all children of that parent. How does the NSFetchRequest look like for this please? Edit: model is like this: student>>dates [one to many, one student have many days] So I want all dates for any given student (selected by touching in student table cell for that student), then populate dates table with dates for that student. Thanks!

Create Section With Complex Linq query

I'm trying to create a section with linq from xml file. my xml file build like this: <root> <Item> <name>a</name> <status>new</status> </Item> <Item> <name>b</name> <status>old</status> </Item> </root> I want to create the section by the following way if the status tag = "new it will create an entry element and if its old it will create a stringelement i thought of something like this new section() { from x in myXdoc.Descendants("Item") where x.element("Status").value == "new" || x.element("Status").value == "old" ?????? }