Note that there are some explanatory texts on larger screens.

plurals
  1. POcannot pass the obj-c class obj to another view
    text
    copied!<p>I have 3 classes</p> <p>First -> MainViewController:</p> <pre><code>@interface MainViewController : UIViewController { UtilityBadah *utility; } @property (strong, nonatomic) NSManagedObjectContext *managedObjectContext; - (IBAction)option; @end @implementation MainViewController @synthesize managedObjectContext = _managedObjectContext; (IBAction)option{ UtilityBadah *util = [[UtilityBadah alloc] initWithContext:_managedObjectContext]; OptionController *ovc = [[OptionController alloc] init]; ovc.util = util; ovc.managedObjectContext = _managedObjectContext; [self.navigationController pushViewController:ovc animated:YES]; [util release]; [ovc release]; } @end </code></pre> <p>Second -> UtilityBadah:</p> <pre><code>@interface UtilityBadah : NSObject { NSManagedObjectContext *managedObjectContext; NSString *kitab; NSString *lagu; NSString *font; NSString *sizefont; } @property (nonatomic, retain) NSManagedObjectContext *managedObjectContext; @property (nonatomic, retain) NSString *kitab; @property (nonatomic, retain) NSString *lagu; @property (nonatomic, retain) NSString *font; @property (nonatomic, retain) NSString *sizefont; (id) initWithContext: (NSManagedObjectContext *) context; @end @implementation UtilityBadah @synthesize managedObjectContext; @synthesize kitab; @synthesize lagu; @synthesize font; @synthesize sizefont; -(id) initWithContext: (NSManagedObjectContext *) context { NSError *err; NSFetchRequest *request = [[NSFetchRequest alloc] init]; NSEntityDescription *enDesc = [NSEntityDescription entityForName:@"OptionDB" inManagedObjectContext:context]; [request setEntity:enDesc]; NSArray *arrData = [context executeFetchRequest:request error:&amp;err]; for (OptionDB *data in arrData) { lagu = data.lagu; kitab = data.kitab; font = data.font; sizefont = data.sizefont; } return self; } </code></pre> <p>Thrid -> OptionController:</p> <pre><code>@interface OptionController : UIViewController{ NSManagedObjectContext *managedObjectContext; UtilityBadah *util; } @property (nonatomic, retain) NSManagedObjectContext *managedObjectContext; @property (nonatomic, retain) UtilityBadah *util; @end (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { bla..bla.. NSLog(@"value is %@",self.util.kitab); cell.textLabel.text = [listData objectAtIndex:row]; return cell; } </code></pre> <p>i wonder why this piece of code:</p> <pre><code>NSLog(@"value is %@",self.util.kitab); </code></pre> <p>cause an error "Receiced signa: "EXC_BAD_ACCESS" ? i wonder ther somthing wrong the way i passed the UtilityBadah object from MainViewController to my OptionController.</p> <p>Many thanks for any answer.</p> <p>P.S what is wrong with my xcode 4.2 error information, why it always show "Program received signal: "EXC BAD ACCESS"? cant it be informative?</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