我是编程新手,所以这里的任何人都可以告诉我以下内容是否在 Objective-C 中有效。谢谢。
@interface MainViewController : UIViewController
{
id iTempStore;
}
@property (nonatomic, assign) id iTempStore;
// FirstViewController
@interface FirstViewController : UIViewController
{
MainViewController* pParent;
}
-(void) SomeFunction
{
m_pParent = [[[MainViewController]alloc]init];
NSString* pTest = [[[NSString alloc] initWithString:@"Test"]autorelease];
// Is this valid way to store an object ???
[m_pParent setITempStore: pTest];
// Check Value
NSString* pValue = [m_pParent iTempStore];
NSLog(@"Value is: %@", pValue);// Value is: Test
[m_pParent release];
}