@class CoreServer;
- This line is a forward declaration of the
CoreServer class. It informs the compiler that the CoreServer class exists without providing its full definition. This is useful for avoiding circular dependencies and keeping the compilation process efficient.
/**
* Server is an instance of V2Ray. At any time, there must be at most one Server instance running.
*/
- This comment serves as documentation for the class. It explains the purpose of the
CoreServer class, stating that it represents an instance of V2Ray and emphasizes that only one instance of Server should exist at any given time. Proper documentation helps other developers understand the class's usage and constraints.
@interface CoreServer : NSObject <goSeqRefInterface, CoreServer> {
}
- This line defines the
CoreServer class, which inherits from NSObject (the base class for most Objective-C classes). It also conforms to two protocols: goSeqRefInterface and CoreServer. Protocols define methods that the class must implement, allowing for polymorphism. The empty curly braces {} indicate that there are no instance variables defined directly in this interface.
@property(strong, readonly) _Nonnull id _ref;
- This line declares a property named
_ref of type id, which can hold a reference to any object. The strong attribute indicates that this property maintains a strong reference to the object it points to, preventing it from being deallocated while it's still in use. The readonly attribute means that this property can only be read, not modified after initialization. The _Nonnull keyword specifies that this property cannot be nil, enhancing safety by ensuring that the reference is always valid.
- (nonnull instancetype)initWithRef:(_Nonnull id)ref;
- This line declares an initializer method for the
CoreServer class. It takes a parameter ref of type id (which cannot be nil, as indicated by _Nonnull) and returns an instance of the class (instancetype). This initializer allows the creation of a CoreServer object with a reference to another object, typically needed for establishing its internal state or functionality.
- (BOOL)close:(NSError* _Nullable* _Nullable)error;
- This method declaration specifies a
close method that returns a Boolean value indicating success (YES) or failure (NO). It takes a pointer to an NSError object as a parameter (which can be nil, indicated by _Nullable), allowing the method to report errors encountered during execution. This pattern is common in Objective-C for methods that may fail.
- (BOOL)start:(NSError* _Nullable* _Nullable)error
- Similar to the
close method, this declares a start method that also returns a Boolean value. It takes an optional NSError pointer, allowing the method to report errors. This suggests that starting the server may involve operations that could fail, and the caller can handle errors accordingly.
@end
- This marks the end of the
CoreServer class interface definition. It signifies that no further declarations or implementations are included in this block.