Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the reason behind giving Underscore in private header files of apple

I have seen many .h ( Private API's ) of apple. Most of the variables / structures / enums / classes have _ as prefix.

#import <Foundation/NSValue.h>
#import <Foundation/NSObjCRuntime.h>

@class NSString;

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

My question is,

What is reason behind giving underscore & typedef them again with proper one?

like image 279
Sagar Kothari Avatar asked Dec 08 '25 10:12

Sagar Kothari


1 Answers

Objective-C has a globally open name space. It's important that all names be unique. In addition to the reasons given previously, Apple reserves all underscore names for itself. This will help prevent accidental name collisions.

like image 179
TechZen Avatar answered Dec 10 '25 01:12

TechZen