Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Build a Self-Destructing Message iPhone App Using Parse.com as a Backend and Adding Users Signing Up New Users: Part 2 (PFUser)

Chris Stahl
Chris Stahl
235 Points

HELP! Signing Up New Users: Part 2 (PFUser): UIAlertView is depreciated.

Can someone please just give me the correct code to enter at the end of this?

// // SignupViewController.m // Memory Jar // // Created by Chris Stahl on 12/29/15. // Copyright © 2015 Memory Jar. All rights reserved. //

import "SignupViewController.h"

import <Parse/Parse.h>

@interface SignupViewController ()

@end

@implementation SignupViewController

  • (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. }

  • (IBAction)signup:(id)sender { NSString *username = [self.usernameField.text stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]]; NSString *password = [self.passwordField.text stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]]; NSString *email = [self.emailField.text stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]]; NSString *phone = [self.phoneField.text stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];

    if ([username length] == 0 || [password length] == 0 || [phone length] == 0 || [email length] == 0) { UIAlertController * alert= [UIAlertController alertControllerWithTitle:@"Oops!" message:@"Please enter a Username, Passoword & Email Address" preferredStyle:UIAlertControllerStyleAlert];

    UIAlertAction* ok = [UIAlertAction
                         actionWithTitle:@"OK"
                         style:UIAlertActionStyleDefault
                         handler:^(UIAlertAction * action)
                         {
                             [alert dismissViewControllerAnimated:YES completion:nil];
    
                         }];
    UIAlertAction* cancel = [UIAlertAction
                             actionWithTitle:@"Cancel"
                             style:UIAlertActionStyleDefault
                             handler:^(UIAlertAction * action)
                             {
                                 [alert dismissViewControllerAnimated:YES completion:nil];
    
                             }];
    
    [alert addAction:ok];
    [alert addAction:cancel];
    
    [self presentViewController:alert animated:YES completion:nil];
    

    } else { PFUser *newUser = [PFUser user]; newUser.username = username; newUser.password = password; newUser.email = email;

1 Answer

Chris, here is a full template for the social network application: Click Here.