0

I want to translate this code from Swift to Objective C:

typealias Completion = ([Media]?) -> Void

I have look over Stack Overflow posts, but I don't see the answer for this.

2 Answers 2

3
typedef void (^CompletionBlock) ( NSArray<Medial*>* _Nullable array);
Sign up to request clarification or add additional context in comments.

5 Comments

It says: unknown type name 'nullable'. typedef void (^Completion) (NSArray<Media*>* array); is good.
Updated answer. Now should work fine. It defines that your array may be nil. In Swift code that it's optional value. It must be there to fully be as your swift code. And yes, it will work without it as well, only problem may appear when you will be translating this Objective-C code into Swift code. Than it will be translated as non optional value (if without _Nullable)
Then in func load(mediaType: MediaType, completion: Completion) -> - (void)load:(MediaType *)mediaType completion:(Completion)completion;
It says: Pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified)
It wan't now for you to add such things to your code. I suppose it want to determine other objects nullabilities. Try transforming into - (void)load:(nonnull MediaType *)mediaType completion:(nonnull Completion)completion;
0
typedef void (^CompletionBlock) (NSArray* array);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.