开发者

Why don't we use * while we create the object of NSRange

开发者 https://www.devze.com 2023-01-31 18:49 出处:网络
Can anybody tell me that Why 开发者_高级运维don\'t we use * with NSRange object.Whenever i use * with NSRange it gives error why it\'s giving error?Because NSRange is a struct, not a class. Structs ar

Can anybody tell me that Why 开发者_高级运维don't we use * with NSRange object.Whenever i use * with NSRange it gives error why it's giving error?


Because NSRange is a struct, not a class. Structs are value types, and therefore you do not use pointers with them like you do with class instances (* is the pointer dereferencing operator).


This is the structure of NSRange :

typedef struct _NSRange {
      NSUInteger location;
      NSUInteger length;
} NSRange;

Now tell me do you think we required any pointer ? why we required the pointer ? If you can give the answer than that is your solution.

0

精彩评论

暂无评论...
验证码 换一张
取 消