0

I want to know If I can initialize a UILabel from another initialized UILabel Like this :

_brandNameLabel = [[SharedDataObject shared]brandNameLabel];
[[self view]addSubview:_brandNameLabel];

I found that this code will create a pointer to the initialized object, so what is the way to initialize my new object ?

OXXY
  • 1,047
  • 2
  • 18
  • 43
  • to initialize new object you need to alloc init... and not to get shared instance of another object !! – Rahul Shirphule May 18 '16 at 06:18
  • u r using singleton class to initailize the object that why its pointing to same object . – user3306145 May 18 '16 at 06:27
  • I don't know the scope and property of your [[SharedDataObject shared]brandNameLabel] label and _brandNameLabel label. It could be assign or strong depends on the property. If you want to create your own label and have to have the ownership, instead of inferring the complete label like do like this UILabel *myOwnLabel = [[UILabel alloc]init]; myOwnLabel.text = _brandNameLabel.text; myOwnLabel.frame = _brandNameLabel.frame; [[self view]addSubview:myOwnLabel]; Please don't mind if my answer is irrelevant. – sasi kumar May 18 '16 at 06:44

0 Answers0