I know this is probably going to seem really trivial to some, but to me it's really confusing, the problem I'm having is sometimes the debugger throws errors and without changing anything it says successful and shows 0 errors, other times it shows 20 errors but for some reason it duplicates the error to me (there are 20 errors because I have 5 files with the same NSTimer and NSURL code, not exact code is similar with individual calls for showing like twitter, flickr etc loading different urls within 5 seperate .xib files) - Here is what is shows in the debugger for each .m file with the NSURL and NSTimer implemented:
Code:
warning: property 'activity' requires method '-activity' to be defined - use @synthesize, @dynamic or provide a method implmentation
warning: property 'activity' requires the method 'setActivity:' to be defined - use @synthesize, @dynamic or provide a method implementation
It's actually shown twice. Now this is really confusing to me, I've followed guides from others and I've actually copied their code word for word but changed the obvious text to match my app. Why do I get the above method? How do I fix it with @synthesize activity; because adding that gives me errors I am only one week into iPhone dev, and I'm very new to Mac and programming as a whole so please be gentle and explain things as clear as you possible can.
in my .h files I have roughly the same code, again different for each .nib (as in twitterView, flickerView etc. Here is what I have:
And in my .m i'll post just the timer and url code unless you need me to post the whole file:
Code:
- (void)viewDidLoad {
[super viewDidLoad];
[twitView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://mobile.twitter.com/"]]];
timer = [NSTimer scheduledTimerWithTimeInterval:(1.0/2.0) target:self selector:@selector(loading) userInfo:nil repeats:YES];
}
//Tests condition to see whether web page is loading to either trigger
//or stop the Activity indicator.
-(void)loading{
if(!twitView.loading)
[activity stopAnimating];
else
[activity startAnimating];
}
Although debugger shows me nothing inside the .m file with the timer code it shows 'undeclared selector 'loading' 2 - the code is above for you to view.
Properties are like a shortcut to creating your own getters and setters for member variables in your classes. The @synthesize tells the compiler to create those getter and setter methods.
Really all you need to do is add the line:
@synthesize twitload, activity;
in your .m below the @implementation line
The debugger only gives you the warnings the first time you compile, or after you do a clean target and build again, that is why sometimes you get the warnings and sometimes you get 0 warnings
ok, can you show the top of your .m file. Have you defined activity and twitload with @synthesize?
Also where are you initing UIActivityIndicatorView? are you using
self.activity = xxxxx
i.e. using the setter?
The UIActivityIndicator view is connected to a timer inside a UIWebView on one of the 5 .xib files, I did have @synthesize activity; at in the top of the .m bt it would say undeclared selector 'loading'
Here is my entire .m file:
Code:
#import "twitter.h"
#import "leesitesViewController.h"
@implementation twitter
@synthesize twitload;
-(IBAction)goBack {
leesitesViewController *second2 = [[leesitesViewController alloc] initWithNibName:@"leesitesViewController" bundle:nil];
second2.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:second2 animated:YES];
[second2 release];
}
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
[twitView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://mobile.twitter.com/"]]];
timer = [NSTimer scheduledTimerWithTimeInterval:(1.0/2.0) target:self selector:@selector(loading) userInfo:nil repeats:YES];
}
//Tests condition to see whether web page is loading to either trigger
//or stop the Activity indicator.
-(void)loading{
if(!twitView.loading)
[activity stopAnimating];
else
[activity startAnimating];
}
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
//return (interfaceOrientation == UIInterfaceOrientationPortrait);
return YES;
}
- (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 {
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[twitter release];
[twitView release];
[twitload release];
[activity release];
[super dealloc];
}
@end
Properties are like a shortcut to creating your own getters and setters for member variables in your classes. The @synthesize tells the compiler to create those getter and setter methods.
Really all you need to do is add the line:
@synthesize twitload, activity;
in your .m below the @implementation line
The debugger only gives you the warnings the first time you compile, or after you do a clean target and build again, that is why sometimes you get the warnings and sometimes you get 0 warnings
I must have done something wrong somewhere else because I just added @synthesize activity; to all 5 .m files and it seems to work, I cleaned all targets selected the top file in the list (blue xcode icon) with my app name and then did build and analyze and it shows no errors!
If my app is missing the @synthesize methods will the app store reject this or can I submit it as an update if they approve it?
I submitted my app around 8 hours ago, would it be safer to pull my app and resubmit it with this build?
I must have done something wrong somewhere else because I just added @synthesize activity; to all 5 .m files and it seems to work, I cleaned all targets selected the top file in the list (blue xcode icon) with my app name and then did build and analyze and it shows no errors!
If my app is missing the @synthesize methods will the app store reject this or can I submit it as an update if they approve it?
I submitted my app around 8 hours ago, would it be safer to pull my app and resubmit it with this build?
personally I would pull it and resubmit. Nothing worse than having an app crash immediately.
At the end of the day, submission is taking around 10/11 days so 8 hours isn't much of a loss.
Thanks for the help guys, I appreciate the information and advice, if I pull the app will I loose the app name? I did it yesterday and couldn't submit the app with the same name, is it not possible to rebuild the app and append the version to like 1.0.1 or even just rebuild and resubmit the app in place of the old one?
Thanks for the help guys, I appreciate the information and advice, if I pull the app will I loose the app name? I did it yesterday and couldn't submit the app with the same name, is it not possible to rebuild the app and append the version to like 1.0.1 or even just rebuild and resubmit the app in place of the old one?
Again thanks I owe you both a case of beer
Just go onto iTunesConnect and choose to reject binary. Check you are happy with the name and then set it as "ready for Upload" and then resubmit it.
Thanks for the help guys, I appreciate the information and advice, if I pull the app will I loose the app name? I did it yesterday and couldn't submit the app with the same name, is it not possible to rebuild the app and append the version to like 1.0.1 or even just rebuild and resubmit the app in place of the old one?
Again thanks I owe you both a case of beer
Don't delete the app. Delete the binary upload from the submission. You can keep your new app submission in the store with no binary attached to it. The clock won't start running on the review process until you upload a new version, but everything else will stay in place.
It worries me that you couldn't get your app to run at all, and then you fixed it and submitted it to the store. You would be well advised to spend at least a couple of days testing it, and even give it to friends with different models of iOS devices and OS versions to test on.
You need both testing to see if it works, and feedback on how easy it is to use and possible improvements that would make it better. Rarely do we get anything but a flashlight app right on the first try, and spending the time to refine it is well worth the effort.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
Don't delete the app. Delete the binary upload from the submission. You can keep your new app submission in the store with no binary attached to it. The clock won't start running on the review process until you upload a new version, but everything else will stay in place.
It worries me that you couldn't get your app to run at all, and then you fixed it and submitted it to the store. You would be well advised to spend at least a couple of days testing it, and even give it to friends with different models of iOS devices and OS versions to test on.
You need both testing to see if it works, and feedback on how easy it is to use and possible improvements that would make it better. Rarely do we get anything but a flashlight app right on the first try, and spending the time to refine it is well worth the effort.
Thanks for the response Duncan, I could get my app to run without any glitches or crashes even with heavy use from on my device and the simulator, even with the debugger it showed no errors, I was just having the errors because the @synthesize activity; was missing in the files (I just learned how to fix with one of the previous posts), I had submitted the app when I wasn't having anything displayed in the debugger, and then I re-ran xcode to consider adding/changing some graphic icons and the debugger gave me errors the first time and not after.
I have actually had around 6 people testing the app for the past 2.5 days on 3GS, iPod and iPhone 4's , my app is nothing special it just loads websites within .xib files with a few animations here and there.
I'm going to follow all the helpful advise in response to my post, I'm very appreciative to you all. I'll pull the binary and resubmit my app.
I lie I still have one issue the undeclared selector 'loading'
Here is the only code that uses it:
Code:
- (void)viewDidLoad {
[super viewDidLoad];
[twitView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://mobile.twitter.com/"]]];
timer = [NSTimer scheduledTimerWithTimeInterval:(1.0/2.0) target:self selector:@selector(loading) userInfo:nil repeats:YES];
}
//Tests condition to see whether web page is loading to either trigger
//or stop the Activity indicator.
-(void)loading{
if(!twitView.loading)
[activity stopAnimating];
else
[activity startAnimating];
}
I also release the activity at the end of the file...
Is this a compiler error or a runtime error? What, exactly, does it say? Don't paraphrase - cut and paste the message you are getting, along with a detailed description of the context.
If it is a runtime error, can you get the error when you're running the debug version, and does it show the line that causes it? If so, which exact line of source is generating the error?
Oh, wait. I bet I know what the problem is. NSTimer sends a message with 1 parameter, the timer that triggers the event. Thus, you need to change your loading method to look like this:
Code:
-(void)loading:(NSTimer *)aTimer
And the code that sets up the timer should look like this:
(I added a colon to the end of the selector: "@selector(loading" That tells the compiler that the method loading expects 1 parameter.)
In the future, be crystal clear in describing errors. Cut and paste entire error message, and tell when it occurs: compile-time, run-time, and if at run-time, what you have to do in order to get the error to occur.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
See my last post. I'm fairly certain I gave you the solution.
Duncan is right. I didn't look closely enough to where you were calling the selector....so do what Duncan suggests but no harm in placing the method declaration in the .h as well(but remember it will be
Duncan, my appologies, I did it the way you suggested, changed it in all my appropriate files and it works great, thank you. - I don't know how I missed your post to be honest (these forums always log you out, kind of pointless but makes re-reading and replying to posts a little more taskly or requires more attention to detail when reading).
I have a question, if you don't mind me asking, in my old code it said:
Code:
NSTimer scheduledTimerWithTimeInterval:(1.0/2.0)
and yours says:
Code:
NSTimer scheduledTimerWithTimeInterval: 0.5
What are the differences with the numbers? 1.0/2.0 vs 0.5? Do they mean the same thing? I actually noticed now that with your changes when I click a link in the browser the timer starts again and stops when loading is complete, this was not the case before.
I will be more clear when displaying my errors too, thanks again to you all for taking the time to help me out.
Duncan, my appologies, I did it the way you suggested, changed it in all my appropriate files and it works great, thank you. - I don't know how I missed your post to be honest (these forums always log you out, kind of pointless but makes re-reading and replying to posts a little more taskly or requires more attention to detail when reading).
I have a question, if you don't mind me asking, in my old code it said:
Code:
NSTimer scheduledTimerWithTimeInterval:(1.0/2.0)
and yours says:
Code:
NSTimer scheduledTimerWithTimeInterval: 0.5
What are the differences with the numbers? 1.0/2.0 vs 0.5? Do they mean the same thing? I actually noticed now that with your changes when I click a link in the browser the timer starts again and stops when loading is complete, this was not the case before.
I will be more clear when displaying my errors too, thanks again to you all for taking the time to help me out.
Lee,
The results of 1.0/2.0 and 0.5 will be identical. You want the .0 after yours, to make sure the compiler knows that those are floating point numbers. I thought my style was clearer, since it shows sending a value of 0.5 instead of doing a divide. It's also nominally faster, since the processor doesn't have to do a divide each time.
Your code was probably never calling your loading method since you had the method signature wrong. I would have expected your app to crash, actually, with a message that an unknown selector was sent to an object at some cryptic address.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
The results of 1.0/2.0 and 0.5 will be identical. You want the .0 after yours, to make sure the compiler knows that those are floating point numbers. I thought my style was clearer, since it shows sending a value of 0.5 instead of doing a divide. It's also nominally faster, since the processor doesn't have to do a divide each time.
Your code was probably never calling your loading method since you had the method signature wrong. I would have expected your app to crash, actually, with a message that an unknown selector was sent to an object at some cryptic address.
The App run perfectly fine in the simulator and on my iPhone 4 - I don't know enough about programming yet to understand all this, I'm simply trying to self educate myself on it all and it's very slowly sinking in.
The only errors I was getting in the debugger about the object was what I posted in my first post which were the following:
Code:
warning: property 'activity' requires method '-activity' to be defined - use @synthesize, @dynamic or provide a method implmentation
warning: property 'activity' requires the method 'setActivity:' to be defined - use @synthesize, @dynamic or provide a method implementation
Confuses me, probably makes sense to you pro's and hopefully one day me too.