2011-07-03 7 views
0

私はオブジェクト名がusrです。私はビューを変更したいと思って、それを新しいビューに渡したいと思います。このオブジェクトをどのように渡すことができますか?それをやってのオブジェクトを別のビューに渡す

RVUser *usr = [[RVUser alloc] init]; 

UIViewController* exampleController = [[exampleClass alloc] initWithNibName:@"RVListsController" bundle:nil]; 
if (exampleController) { 
    exampleController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; 
    [self presentModalViewController:exampleController animated:YES]; 
     if (exampleController.title == nil) { 
      NSLog(@"enters"); 
      //exampleController.title = @"Revistas Destacadas"; 
     } 
     [exampleController release]; 
    } 
} 

答えて

1

一つの方法は、exampleClassにタイプRVUserのプロパティを宣言し、exampleControllerを作成した後、そのプロパティに割り当てることです。

0

あなたが代わりのUIViewControllerのカスタムのUIViewControllerとしてExampleControllerのインスタンスを宣言したいと思う[self presentModalViewController:exampleController animated:YES];

RVUser *usr = [[RVUser alloc] init]; 

UIViewController* exampleController = [[exampleClass alloc] initWithNibName:@"RVListsController" bundle:nil]; 

if (exampleController) { 
    exampleController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; 

    if (exampleController.title == nil) { 
     NSLog(@"enters"); 
     //exampleController.title = @"Revistas Destacadas"; 
    } 

    //TODO: Set exampleController properties, declared as @property (nonatomic, release) RVUser *passedUsr; 
    //exampleController.passedUsr = usr; 
    //[usr release]; 

    [self presentModalViewController:exampleController animated:YES]; 
} 

[exampleController release]; 
+0

良い点ですが、彼の質問には対応していません – RyanR

0

を使用する前にプロパティを設定する必要があります - あなたが呼び出す場合、これはあなたのコード補完を与えると時間の警告をコンパイルします。メソッド/プロパティは終了しません。今、あなたが渡すことができ

@synthesize user; 

@property (nonatomic, retain) RVUser *user; 

と実装ファイルに:次に、そのような、型RVUserの性質を持っている(また、命名規則ガイドを読んで)でExampleClassのあなたの定義を変更そのコントローラへのごオブジェクトあなたはそれを表示する前に:

ExampleController.user = usr; 

あなたは本当に彼らがこれとあなたがどうかを知る必要があることをより多くをカバーする、アップルの開発者向けサイトでのイントロガイドをお読みくださいあなたはiOSアプリを書いてみたいです。

関連する問題