CTParagraphStyleRef paraStyle = CTParagraphStyleCreate(alignSettings, 1);
NSDictionary *dictionary = [NSDictionary dictionaryWithObject:paraStyle forKey:kCTParagraphStyleAttributeName];开发者_开发百科
I get a warning on the second line of code "Passing argument 2 from incompatible pointer type " How can I get rid of this warning?
paraStyle
is no object, so you cant store it as one. try setValue:forKey:
on a NSMuteableDictionary and valueForKey:
to retrieve it.
Or wrap your value in a NSValue object.
You are getting the warning because kCTParagraphStyleAttributeName
is not an object and can't be used as a key in an NSMutableDictionary
. Keys in an NSMutableDictionary
must be Objective-C objects that conform to the NSCopying
protocol. The CTParagraphStyleRef
can't be stored in the dictionary either, because it is likewise not an Obj-C object.
You may want to try using a CFMutableDictionary
, whose keys and values can be any C type.
精彩评论