문제

Currently I have a view UIView *myView;. I would like to add data to the view by saying something like myView.stringdata = @"whatever";. How can I do this? Sorry for the simple question I'm new to Xcode.

도움이 되었습니까?

해결책

You can't add random data to views. You can subclass UIView if you want and add a property to the class and store your string there. Or you could make a property in the ViewController that is driving your UIVIew and assign the string to it.

다른 팁

You cannot add data to an instance of a class if the class does not have an ivar + accessor or a property for it.

You need to use one of the following approaches:

Subclass Category Delegate Associative Objects Composition Collections

All of these involve modifying the class as a whole in your app (or any app if it were a framework class in a framework visible at the user or system level) or they involve creating new classes or association by being in collection member.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top