iphone - UITable view: didselectrowatIndexPath for multiple rows -


"itemprop =" text ">

I have a table view (HomeViewController) in the form of items:

locations & gt;

Reporting & gt;

Installation & gt;

I am able to do this with the help of "didselectrowatIndexPath" for the same line, but when I am trying to do this with multiple rows (if others are created), error is not found But still are unable to click on any (places, reporting, or settings) I have imported all three files above. My code:

  - (zero) tableView: (UITableView *) tableView didSelectRowAtIndexPath: (NSIndexPath *) indexPath {if ([[menuList objectAtIndex: indexPath.row] isEqual: @ "location"] ) {LocationViewController * locationViewController; LocationViewController = [[LocationViewController alloc] initWithNibName: @ "Location View Controller" bundle: zero]; LocationViewController.menuList = [menuListObjectIndex: indexPath.row]; [Self. Navigation Controller Push ViewController: Animated Location View Controller: Yes]; } And if (([[menuList object at index: indexpath.org] is: @ "reporting"]) (reporting * reporting; reporting = [[all reporting] initWithNibName: @ "reporting" bundle: zero]; reporting.menuList = [ MenuList ObjectTime: IndexPath.ro] [Auto Navigation Controller Push ViewController: Animated Reporting: Yes];} // [locationViewController release];}   

About my Reliance statement Thanks!

isEqual tests the object's resemblance on another object if the string in your menuList array is in upper case, that's fine. If they want to be in your example before the code, then you In addition, if they are both NSStrings, then you should use isEqual instead of isEqualToString . (UITableView *) tableView didSelectRowAtIndexPath: (NSIndexPath *) indexPath { NSString * arrayValue = [menuList objectAtIndex: indexPath.row - (zero) tableView

 : You can do something like this Can test this by doing the like]; NSString * myValue = @ "LOCATION"; NSLog (@ "Array Value: '% @' My Value: '% @'", array, value, myValue); }   

The release is not valid because the object is "out of scope".

One object scope is the current "view" code base for that variable. Here are some examples:

  - (zero) aRandomFunction {/ * Here is a variable / object, its scope is the whole function because it has been declared directly in the function. It is used for all the constructions (within the function) * / NSString * myString = @ "My String"; If (yes) {nslog (@ "% @", migrating); // myString is appearing here because its scope}} - (zero) another random function {if (yes) {/ * here, because we have declared VER within an if statement, this is not a direct object of the function . Instead, if I is a direct child of the statement and is therefore "visible" only, if the statement * / NSString * myString = @ "My String"; NSLog (@ "% @", MyString); // myString is appearing here because its scope is} NSLog (@ "% @", MyString); // but not available here because it is out of the field}   

In short, the scope of a variable is its direct parent creation and produces all the children of their parents.

So there are two ways to do your example: My favorite is this way:

  - (zero) aFunctionToPushAViewController {UIViewController * nextPage = NULL; If (yes) {next page = [[custom view controller alloc] initWithNibName: zero bundle: zero]; } Else {nextPage = [[EditedViewCentron alloc] initWithNibName: zero bundle: zero]; } [Self. Navigation controller Push ViewController: Animated Next Picture: Yes]; [Next page release]; }   

Or ... you can only release it in the statement ...

  - (zero) aFunctionToPushAViewController {if (yes) { CustomViewController * Next Page = [[[CustomView Controller alloc] initWithNibName: Zero Bundle: Zero]; [Self. Navigation controller Push ViewController: Animated Next Picture: Yes]; [Next page release]; } Other {Quadratic View Controller * Next Page = [[Extra Viewer Alloc] initWithNibName: Zero Bundle: Zero]; [Self. Navigation controller Push ViewController: Animated Next Picture: Yes]; [Next page release]; }}    

Comments