n8chur / AUTExtObjC

Some handy extensions to make your life easier when writing Objective-C

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Featuring:

let and var

Pretend that you're writing Swift (when you're really writing Objective-C):

let value = @"A constant string, with an inferred type of NSString *";
var value = @"A string that can be reassigned, with an inferred type of NSString *";

value = @"A new value";

AUTAssertNotNil

Makes repeated NSParameterAssert(argument != nil); boilerplate that much easier ✨.

AUTAssertNotNil(something, somethingElse, anotherThing);

AUTNotNil

Like Swift's !, but in Objective-C:

- (void)doSomethingWith:(nonnull id)argument;

@property (nullable) id property;

// ...

[self doSomethingWith:AUTNotNil(self.property)];

AUTFallback

Like Swift's ??, but in Objective-C:

- (void)doSomethingWith:(nonnull id)argument;

@property (nullable) id property;

// ...

[self doSomethingWith:AUTFallback(self.property, @"fallback")];

AUTStrongifyOr

Same as @strongify(...), but with an escape hatch if strongification fails.

@strongifyOr(self) return [RACSignal empty];

AUT_UNAVAILABLE_DESIGNATED_INITIALIZER

Reduces boilerplate when opting out of designated initializers.

Header.h

- (instancetype)initWithCoder:(NSCoder *)aDecoder NS_UNAVAILABLE;

Implementation.m

- (instancetype)initWithCoder:(NSCoder *)aDecoder AUT_UNAVAILABLE_DESIGNATED_INITIALIZER;

AUTLocalizationNotNeeded()

Tells the clang analyzer that a string does not need localization if the CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED build setting is on.

label.text = AUTLocalizationNotNeeded(@"Secret Developer Menu");

About

Some handy extensions to make your life easier when writing Objective-C

License:MIT License


Languages

Language:C 84.5%Language:Objective-C 14.0%Language:C++ 1.5%