[Solved] Bank Account iOS App Structure


The problem you’re facing is that you’re creating a new bank account every time instead of maintaining a single account and adding to it.

In your original program you created an array of accounts acc that persisted during the lifetime of the user input. Since you’ve moved from a procedural program to a UI program with a run loop, you’ll need a more persistent place to store it.

Generally, a good spot would be a property on your view controller or higher up if the objects need to persist longer than the view controller:

@property Account *account;

...

- (id)init
{
    if (self) {
        _account = [[Account alloc] init];
    }
    return self;
}

...

[self.account deposit:(damount)];

Since this is for class, you will probably want to review your textbook for topics like properties and instance variables.

solved Bank Account iOS App Structure