【问题标题】:Passing a Custom Object, an NSObject sub - Class, with a Storyboard Segue使用 Storyboard Segue 传递自定义对象、NSObject 子类
【发布时间】:2012-07-06 05:08:32
【问题描述】:

SimpleTest 对象:

我的 .h(标题)代码:

#import <Foundation/Foundation.h>
@interface SimpleTest : NSObject
@property (strong, nonatomic) NSString *tested;
@end

我的 .m 代码:​​

#import "SimpleTest.h"
@implementation SimpleTest
@synthesize tested;
@end

只是一个简单的类。我做这个是为了测试,我实际上有一个更大更复杂的对象。

在我的故事板中,如果我在prepareForSegue 中将我没有创建的对象(例如NSString)从我原来的ViewController 传递到我的DestinationViewController,它工作得很好;目标视图控制器很好。当我传递从原始 ViewController 制作的简单对象并设置字符串时,它在目标 ViewController 中返回 null 这里是一些示例代码:

if ([[segue identifier] isEqualToString:@"toInsulinList"]) 
{
    IDataViewController *ivc = [segue destinationViewController];
    ivc.pListObj = self.pListObj; //My complex object, returns null in dest vc 
    ivc.tester = @"Tested"; //this is an NSString in dest vc - works fine
    simpleTest.tested = @"testObj";   
    ivc.simpleTest = self.simpleTest; //my simple object, returns null in dest vc
}

对此有任何猜测吗?任何帮助深表感谢。

【问题讨论】:

    标签: parameter-passing uistoryboard segue uistoryboardsegue custom-object


    【解决方案1】:

    对象为零。菜鸟错误。 :(

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-12-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-19
      • 1970-01-01
      相关资源
      最近更新 更多