Fredlo2010 Fredlo2010 - 1 year ago 48
iOS Question

What does this property declaration mean?

So I am learning some Xcode and today I was following a tutorial online and I came across using the property


I was looking at the header file and I cannot read this piece of code. Directly from the file. Note that I do not want to understand how to use it but rather I am trying to understand how it's defined.

/* You may specify the font, text color, and shadow properties for the title in the text attributes dictionary, using the keys found in NSAttributedString.h.
@property(nullable,nonatomic,copy) NSDictionary<NSString *,id> *titleTextAttributes NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;

Thanks a lot in advance for the help :)

Answer Source

@property(nullable,nonatomic,copy) NSDictionary<NSString *,id> *titleTextAttributes NS_AVAILABLE_IOS(5_0) UI_APPEARANCE_SELECTOR;

@property(nullable,nonatomic,copy): declaring a property. It is allowed to be nil (nullable). It will have non-atomic semantics which has to do with multi-threading -- meaning, it is by-default not thread safe without some synchronization (don't worry about this) and when it is set, it will make a copy.

NSDictionary<NSString *,id> * - the type of the property is a dictionary that maps strings to any object (id).

titleTextAttributes - the name of the property

NS_AVAILABLE_IOS(5_0) - this is a macro that doesn't do anything for the code, but lets you know that it was available since iOS 5.0


To participate in the appearance proxy API, tag your appearance property selectors in your header with UI_APPEARANCE_SELECTOR.

Appearance property selectors must be of the form:

 - (void)setProperty:(PropertyType)property forAxis1:(IntegerType)axis1 axis2:(IntegerType)axis2 axisN:(IntegerType)axisN;
 - (PropertyType)propertyForAxis1:(IntegerType)axis1 axis2:(IntegerType)axis2 axisN:(IntegerType)axisN;

You may have no axes or as many as you like for any property. PropertyType may be any standard iOS type: id, NSInteger, NSUInteger, CGFloat, CGPoint, CGSize, CGRect, UIEdgeInsets or UIOffset. IntegerType must be either NSInteger or NSUInteger; we will throw an exception if other types are used in the axes.