objective c init unavailable

Asked on 08/01/2024

1 search

It seems like you're asking about the init_unavailable attribute in Objective-C. While the provided context doesn't directly address this, I can provide some general information about it.

In Objective-C, the init_unavailable attribute is used to mark initializers as unavailable. This is useful when you want to prevent certain initializers from being used, typically because they are not appropriate for the class or could lead to incorrect usage.

Here's an example of how you might use it:

@interface MyClass : NSObject

- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithParameter:(id)parameter NS_DESIGNATED_INITIALIZER;

@end

In this example, the default init method is marked as unavailable, and only the initWithParameter: initializer is allowed.

For more detailed information on initializers and their usage in Swift, you might want to check out the session on Migrate your app to Swift 6, which discusses various aspects of initializers and concurrency in Swift.

If you have any specific questions about the content presented at WWDC, feel free to ask!