Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BlakeBarrett/7c9cceb1d038c0607abbd92d13fd644a to your computer and use it in GitHub Desktop.
Save BlakeBarrett/7c9cceb1d038c0607abbd92d13fd644a to your computer and use it in GitHub Desktop.
Pandora ACE Team, Objective-C/Swift Interview Question.

At Pandora all of our legacy iOS code is written in Objective-C (using ARC), however all new classes/features/work will be written in Swift. In this scenario, you are refactoring a legacy Objective-C file to be more readable. There is a function createSoftButtonWithIdentifier. It takes three arguments: identifier, text and iconValue -- all of which will only ever be used together {id:@1, text: @"List", iconValue: @"list_icon"} -- there are no circumstances under which the arguments will be mixed up.

- (SoftButton *) createSoftButtonWithIdentifier:(NSNumber *)identifier
                                        andText:(NSString *)text
                                   andIconValue:(NSString *)value;
  • How would you improve this by creating a structured data object to group the values together?
  • You may change the function's signature to take your new type.
    • createSoftButtonWithIdentifier function must live in the Obj-C class/cannot be rewritten in Swift.

You may use Objective-C, C or Swift as long as the Swift types translate to Objective-C.

  • How/what would you want to write an XCTestCase unit-test for?
    • Test can be in Objective-C or Swift.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment