Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS

luke jones
luke jones
8,915 Points

adding an array to an array

I asked this question yesterday but don't think I asked the question too well. I'm going to try and ask it a little better this time... import UIKit

class House: NSObject {

var housePerson = []
var houseNumber = ""
var houseAddress = ""
var housePhoneNumber = ""

} class HouseModel{

func getHouse() -> [House] {

    var house = [House()]

    let house1 = House()
    house1.housePerson = ["Steve", "Matthew", "Paul", "Jason"]
    house1.houseNumber = "123"
    house1.houseAddress = "Bob Drive"
    house1.housePhoneNumber = "123456789"
    house.append(house1)

    return house
}

}

class Person { var personName = "" var personAge = "" var personHeight = "" var personWeight = "" var personSex = "" } class PersonModel{

func getPerson() -> [Person] {

    var person = [Person]()

    let person1 = Person()
    person1.personName = "Steve"
    person1.personAge = "23"
    person1.personHeight = "180cm"
    person1.personWeight = "200lbs"
    person1.personSex = "M"
    person.append(person1)

    let person2 = Person()
    person2.personName = "Matthew"
    person2.personAge = "27"
    person2.personHeight = "165cm"
    person2.personWeight = "170lbs"
    person2.personSex = "M"
    person.append(person2)

    return person

} }

I want to add person1 to the House array rather than them being two separate arrays. Hopefully that makes sense.