Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ialjumeri

macrumors newbie
Original poster
Jan 10, 2011
2
0
Iam iphone developer learner, following tutorial was made for iphone 3.0 (just to let u know), and the iphone simulator on iphone 4.2.

what is the issue?

I am exactly following the book i am reading from (Sams Teach yourself iphone application in 24 hours)

when I run the xcode .. the iphone simulator launched and the app crashed immediately before opening it..

how to fix that?

Here I am copying the code..

ooh one more thing it gives me warning on

withString:thePlace.text];
withString:theVerb.text];
withString:theNumber.text];


massage saying " NSString 'may not respond to'-StringByReplacingOccrrencesOfString:withString"


============================================
#import <UIKit/UIKit.h>

@interface FiledButtonFun1ViewController : UITableViewController {
IBOutlet UITextField *thePlace;
IBOutlet UITextField *theVerb;
IBOutlet UITextField *theNumber;
IBOutlet UITextView *theStory;
IBOutlet UITextView *theTemplate;
IBOutlet UIButton * generateStory;
}

@property (retain, nonatomic) UITextField *thePlace;
@property (retain, nonatomic) UITextField *theVerb;
@property (retain, nonatomic) UITextField *theNumber;
@property (retain, nonatomic) UITextView *theStory;
@property (retain, nonatomic) UITextView *theTemplate;
@property (retain, nonatomic) UIButton * generateStory;

-(IBAction)createStory:(id)sender;

@end

=====================================



#import "FiledButtonFun1ViewController.h"

@implementation FiledButtonFun1ViewController

@synthesize thePlace;
@synthesize theVerb;
@synthesize theNumber;
@synthesize theStory;
@synthesize theTemplate;
@synthesize generateStory;

-(IBAction)createStory:(id)sender {
theStory.text=[theTemplate.text
StringByReplacingOccurrencesOfString:mad:"<place>"
withString:thePlace.text];
theStory.text=[theStory.text
StringByReplacingOccurrencesOfString:mad:"<verb>"
withString:theVerb.text];
theStory.text=[theStory.text
StringByReplacingOccurrencesOfString:mad:"<number>"
withString:theNumber.text];
}



- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}


-(void)dealloc {
[thePlace release];
[theVerb release];
[theNumber release];
[theStory release];
[theTemplate release];
[generateStory release];
[super dealloc];
}

@end
========================================
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
Look very carefully at the NSString documentation. Is the method called StringByReplacingOccrrencesOfString:withString or stringByReplacingOccrrencesOfString:withString. Capitalisation of letters is important.
 

ialjumeri

macrumors newbie
Original poster
Jan 10, 2011
2
0
Thanks, guys

Yes, in ( stringByReplacingOccrrencesOfString:withString)

the (s) in the beginning should be small.. I changed it and.. the warning was gone.. fixed

Yet,

the app still does not want to open .. is just trying to launch, but immediately closed...

It seems a common problem for the beginner developer .. !

I cannot go further in learning if this problem still exists..

Help..
 

sdd

macrumors newbie
Jan 10, 2011
9
0
Download the books resources if you have not done so already and go into the folder which corrisponds to the tutorial your doing. In there you should see an Xcode project file. Click this and Xcode will open. Use the authors completed code to check your project code matches that. Also check you have connected the outlets and actions correctly in Interface Builder by opening the controller xib file. Use the document plane to see your existing configurations you have set in your File Owner.

Sorry hard typing this on the iPhone
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.