Note that there are some explanatory texts on larger screens.

plurals
  1. POaddObject: to array not working (array still nil)
    primarykey
    data
    text
    <p>This app is a table view with a tab bar controller. I am logging the count of the array: arrayOfFavourites and even though i add an object is continues to have a nil value, my relating code, all objects shown are allocated and initialized in the code (previous or present) some are instances and some are properties:</p> <p>ListViewController.m:</p> <pre><code> -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"TOUCHED CELL!"); // Push the web view controller onto the navigation stack - this implicitly // creates the web view controller's view the first time through [[self navigationController] pushViewController:webViewController animated:YES]; // Grab the selected item entry = [[channel items] objectAtIndex:[indexPath row]]; if (!entry) { NSLog(@"!entry"); } // Construct a URL with the link string of the item NSURL *url = [NSURL URLWithString:[entry link]]; // Construct a request object with that URL NSURLRequest *req = [NSURLRequest requestWithURL:url]; // Load the request into the web view [[webViewController webView] loadRequest:req]; // Take the cell we pressed // IMPORTANT PART CELL = [tableView cellForRowAtIndexPath:indexPath]; [webViewController setItem:entry]; webViewController = nil; webViewController = [[WebViewController alloc] init]; [entry release]; } </code></pre> <p>WebViewController.m:</p> <p>You shake to favorite a cell</p> <pre><code> -(void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event { cellToPassOn = nil; NSLog(@"Favouriting"); // YES I KNOW SPELLING // This is pretty simple, what we do is we take the cell we touched and take its title and link // then put it inside an array in the Favourites class Favourites *fav = [[Favourites alloc] init]; ListViewController *list = [[ListViewController alloc] init]; [self setCellToPassOn: [list CELL]]; if (!item) { NSLog(@"NILLED ITEM"); } [[fav arrayOfFavourites] addObject:[item autorelease]]; [fav setCell: cellToPassOn]; [fav release]; [list release]; item = nil; } </code></pre> <p>Favourites.m:</p> <pre><code> -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { arrayOfFavourites = [[NSMutableArray alloc] init]; NSLog(@"ROWS NO."); NSLog(@"%i", [arrayOfFavourites count]); return [arrayOfFavourites count]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload