Passing a Custom Object, an NSObject sub - Class, with a Storyboard Segue
-
19-06-2021 - |
Frage
SimpleTest Object:
my .h (header) code:
#import <Foundation/Foundation.h>
@interface SimpleTest : NSObject
@property (strong, nonatomic) NSString *tested;
@end
my .m code:
#import "SimpleTest.h"
@implementation SimpleTest
@synthesize tested;
@end
Just a simple class. I made this for a test, I actually have a bigger more complex object.
in my storyboard if I pass an object I didn't make, for example an NSString, in the prepareForSegue from my original ViewController to my DestinationViewController, it works just fine; the destination view controller gets it fine. When I pass the simple object I made from the origin ViewController and set the string, it returns null in the Destination ViewController here is some sample code:
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
}
Any guesses on this? Any help is much appreciated.
Lösung
The object was nil. Rookier error. :(
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow