Swift: working apply()