objective c - Property of a property not being set? -


मेरे पास OJTest.h है जिसमें:

  @property (nonatomic) int testVal;  

ViewController.h में:

  #import "OJTest.h" @ प्रॉपर्टी (मजबूत, गैर-नॉटमिक) ओजेस्ट * testObject;  

ViewController.m में:

  - (शून्य) दृश्यडिडलोड {[सुपर व्यूडिडलोड]; Self.testObject.testVal = 100; NSLog (@ "% i", self.testObject.testVal); }  

फिर भी कंसोल प्रिंट 0. मैं क्या याद आ रही है / गलतफहमी?

आपका testObject नहीं बनाया जा रहा है अपने दृश्य में निम्न प्रयास करें DidLoad:

  self.testObject = [[OJTest alloc] init]; Self.testObject.testVal = 100;  

Comments

Popular posts from this blog

c# - SignalR: "Protocol error: Unknown transport." when navigating to hub -

class - Kivy: how to instantiate a dynamic classes in python -

python - mayavi mapping a discrete colorbar on a surface -