Structs and Tydefs in Objective C

A struct is a structure that holds multiple related pieces of data.  

struct Song {
    int id;
    char name;
    float songLength;
    float bpm;
}

A typedef defines an alias for a type declaration, allowing you to use that alias like a standard data type. With the declaration below, you would then be able to instantiate new songs like "Song richGirl" (opposed to "struct Song richGirl;")

typedef struct {
    int id;
    char name;
    float songLength;
    float bpm;
} Song;

String format specifiers in Objective-C

To include a variable in a string in objective-c, you can use string format specifiers with optional length modifiers.

  • %i  - Integer
  • %c - character
  • %d - Signed decimal Integer
  • %e - Scientific notation using e character
  • %E - Scientific notation using E character
  • %f - floating point decimal
  • %g - the shortest of either %e or %f
  • %G - the shorter of %E or %f
  • %s - string
  • %u - unsigned decimal

Full list: String Format Specifiers - Apple