Q1. What is the value of s?

NSMutableString *s = [NSMutableString stringWithString: @"123"];
[s appendString: @"456"];

Q2. What’s the value of i after these statements?

NSString *str = nil;
NSInteger i = str.integerValue;

Q3. What value is in str after this line in executed?

NSString str = "test" + " " + "more";

Q4. What does this code print?

    NSPredicate *p2 = [NSPredicate predicateWithBlock:^BOOL(NSString*  evaluatedObject, NSDictionary<NSString *,id> * _Nullable bindings) {
      return evaluatedObject.intValue % 2 == 0;
    NSArray *vals = @[@"1", @"2", @"3"];
    NSArray *n2 = [vals filteredArrayUsingPredicate:p2];
    NSLog(@"%@", n2.firstObject);

Q5. Property defaults include **\_\_\_**?

Q6. What is the key difference between NSDictionary and NSMutableDictionary?

Q7. What is foo?


Q8. What can you glean from this line?

#import "NSString+NameHelper.h"

Q9. What’s wrong with this code?

float x = 5.;

Q10. How many times with this loop be executed?

for (int x=0; x<100; x++) {
  x = x + 1;

Q11. What is this code an example of?

[self addObserver: self forKeyPath: @"val" options:0 context: nil];

Q12. What does ARC stand for?

Q13. What is printed for this code?

int val = 0;
val = 1.5;
printf("%d", val);

Q14. What best describes class inheritance in Objective-C?

Q15. How many keys does this NSDictionary have after this code is executed?

NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys: @"b", @"e", @"a", @"r", nil];

Q16. What is wrong with this code?

NSMutableDictionary *dict1 = [NSMutableDictionary dictionaryWithCapacity:5];
[dict1 setValue:@"key" forKey:@"value"];

Q17. What is printed from this code?

NSData *data = [@"print" dataUsingEncoding:NSASCIIStringEncoding];
NSLog(@"%@", [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]);

Q18. What is different about this function?


Q19. Structs can have **\_\_\_**?

Q20. What is wrong with this code?

@interface MyClass : NSObject
    @property (strong, nonatomic, readonly) NSString *name;

Q21. What is an enums base type for the code below?

typedef enum { Foo1, Foo2} Foo;

Q22. If you want to store a small amount of information (e.g., user settings), whats the best, built-in way to go?

Q23. What are categories used for?

Q24. What is this Objective-C code checking?

if ([keyPath isInstanceOf:[NSString class]]) {

Q25. What is this a declaration of?


1. _val = 1;
2. self.val= 100;

Q27. What is wrong with this code?

float x = 2.0;
int(^foo)(int) = ^(int n1) {
  return (int)(n1*x);

Q28. What’s the difference between an array and a set?

Q29. Dot notation can be used for **\_\_\_**?

Q30. What is the value of newVals after this code is executed?

    NSArray *vals = @[@"1", @"2", @"3"];
    NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF.intValue > 1"];
    NSArray *newVals = [vals filteredArrayUsingPredicate:pred];

Q31. How would this function be called?

-(int)foo:(int)a b:(int)c;

Q32. What is the type of the error return value stored in json?

    NSError *error;
    NSData *data;
    id json = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&error];

Q33. What is significant about this function declaration?


Q34. What is printed from this code execution?

    typedef enum {
    } Thing;

    -(void) enumStuff {
        NSLog(@"%d", thing2);

Q35. You are worried about threaded access to a property and possible collision in writing. What directive should you use on the property?