Note that there are some explanatory texts on larger screens.

plurals
  1. POadding search to NSMutable Array with DetailView
    text
    copied!<p>i have project that I'm working on and i need to add search to my <code>uitableview</code>. i have been looking at lots of codes but mostly they are not what i am looking for and i can't modify them . can someone please help me with adding search to my <code>tableview</code>. also i want to push the <code>detailview</code> from <code>searcharray</code>. thank you in advance.</p> <p>here is the .h <code>uitableview</code></p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface Reds : UITableViewController { NSMutableArray *dummyArray; } - (void) setupData; @end </code></pre> <p>here is .m <code>uitableview</code></p> <pre><code>#import "Reds.h" #import "RedsDetail.h" @interface Reds () @end @implementation Reds - (id)initWithStyle:(UITableViewStyle)style { self = [super initWithStyle:style]; if (self) { } return self; } - (void)viewDidLoad { [super viewDidLoad]; [self setupData]; } - (void) setupData { dummyArray = [[NSMutableArray alloc] init]; [dummyArray addObject:[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"dummy 1", @"name" , @"image1.JPG", @"image" , @"dummy 1 description textview", @"description", nil]]; [dummyArray addObject:[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"dummy 2", @"name" , @"image1.JPG", @"image" , @"dummy 2 description textview", @"description", nil]]; [dummyArray addObject:[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"dummy 3", @"name" , @"image1.JPG", @"image" , @"dummy 3 description textview", @"description", nil]]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } #pragma mark - Table view data source - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [dummyArray count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; cell.textLabel.text = [[dummyArray objectAtIndex:indexPath.row] objectForKey:@"name"]; return cell; } #pragma mark - Table view delegate - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if([[segue identifier] isEqualToString:@"DummyDetail"]){ RedsDetail *dummyDetail = [segue destinationViewController]; NSIndexPath *indexPath = [self.tableView indexPathForCell:sender]; dummyDetail.dummyImageString = [[NSString alloc] initWithString:[[dummyArray objectAtIndex:indexPath.row] objectForKey:@"image"]]; dummyDetail.dummyTextString = [[NSString alloc] initWithString:[[dummyArray objectAtIndex:indexPath.row] objectForKey:@"description"]]; dummyDetail.title = [[NSString alloc] initWithString:[[dummyArray objectAtIndex:indexPath.row] objectForKey:@"name"]]; } } @end </code></pre> <p>here is the .h <code>detailview</code></p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface RedsDetail : UIViewController { IBOutlet UIImageView *dummyImage; IBOutlet UITextView *dummyText; NSString *dummyImageString; NSString *dummyTextString; } @property (nonatomic, retain) NSString *dummyImageString; @property (nonatomic, retain) NSString *dummyTextString; @end </code></pre> <p>and finally the .m <code>detailview</code></p> <pre><code>#import "RedsDetail.h" @interface RedsDetail () @end @implementation RedsDetail @synthesize dummyImageString, dummyTextString; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { } return self; } - (void)viewDidLoad { [super viewDidLoad]; dummyImage.image = [UIImage imageNamed:dummyImageString]; dummyText.text = dummyTextString; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } @end </code></pre> <p>i know it might be a easy answer for most of you guys out there but i can't figure it out and i need help. i truly appreciate the time you guys spending in helping me. also i am using xcode 4.5 ios 6 storyboard if that makes a difference in your answers.</p> <p>adrian</p>
 

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