Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 10-08-2010, 08:20 PM   #1 (permalink)
Mobile Apps Developer
 
JoeRCruso's Avatar
 
Join Date: Oct 2010
Posts: 24
JoeRCruso is on a distinguished road
Question Multiple Action Sheets Problem

I've got an application that uses more than one action sheet, and I'm having problems because of it. Adding the actual action sheets is fine, but then when I set what the buttons do, I get the following error:

redefinition of '-[My_Project_NameViewController actionSheet:clickedButtonAtIndex:]'

So Xcode's telling me I can't use this multiple times:

- (void)actionSheetUIActionSheet *)actionSheet clickedButtonAtIndexNSInteger)buttonIndex{

So what do I do? I'm fairly new to coding and objective-c, so please help me out by maybe giving me an example. Thanks!

And what's up with the frowning faces above?!?!?!
JoeRCruso is offline   Reply With Quote
Old 10-09-2010, 02:06 AM   #2 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 108
iphone_bharat is on a distinguished road
Default

Quote:
Originally Posted by JoeRCruso View Post
I've got an application that uses more than one action sheet, and I'm having problems because of it. Adding the actual action sheets is fine, but then when I set what the buttons do, I get the following error:

redefinition of '-[My_Project_NameViewController actionSheet:clickedButtonAtIndex:]'

So Xcode's telling me I can't use this multiple times:

- (void)actionSheetUIActionSheet *)actionSheet clickedButtonAtIndexNSInteger)buttonIndex{

So what do I do? I'm fairly new to coding and objective-c, so please help me out by maybe giving me an example. Thanks!

And what's up with the frowning faces above?!?!?!
Ok so fair enough is the error that u cant use this multiple times, lets go to why?? and then I will give u the solution.
are u familiar with 'C' language....so have u heard like one function declaration and two definitions of that function...NO isn't it...same is the case here...
this function tells what to do when a button on action sheet is clicked
no how it will allow u to define that thing at two different place...

so now lets come to the solution...as u said u have more than one action sheets so give them different names and inside this function give condition on which action sheet the button is clicked for eg below:-

Code:
UIActionSheet *actionSheet1;
UIActionSheet *actionSheet2;
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
if(actionSheet==actionSheet1)
{
do this}
else
if(actionSheet==actionSheet2)
{do that}
}
And for avoiding smileys enclose ur code in <CODE> tags as I have done above

Last edited by iphone_bharat; 10-09-2010 at 02:09 AM.
iphone_bharat is offline   Reply With Quote
Old 10-14-2010, 07:05 PM   #3 (permalink)
Mobile Apps Developer
 
JoeRCruso's Avatar
 
Join Date: Oct 2010
Posts: 24
JoeRCruso is on a distinguished road
Default Thanks!

Quote:
Originally Posted by iphone_bharat View Post
Ok so fair enough is the error that u cant use this multiple times, lets go to why?? and then I will give u the solution.
are u familiar with 'C' language....so have u heard like one function declaration and two definitions of that function...NO isn't it...same is the case here...
this function tells what to do when a button on action sheet is clicked
no how it will allow u to define that thing at two different place...

so now lets come to the solution...as u said u have more than one action sheets so give them different names and inside this function give condition on which action sheet the button is clicked for eg below:-

Code:
UIActionSheet *actionSheet1;
UIActionSheet *actionSheet2;
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
if(actionSheet==actionSheet1)
{
do this}
else
if(actionSheet==actionSheet2)
{do that}
}
And for avoiding smileys enclose ur code in <CODE> tags as I have done above
Oooohhh... Thanks a lot! I really should try to learn more about Obj. C. Maybe I'll get a book or something. Again, thanks! This will help a lot in future apps.
JoeRCruso is offline   Reply With Quote
Old 10-15-2010, 10:20 AM   #4 (permalink)
Mobile Apps Developer
 
JoeRCruso's Avatar
 
Join Date: Oct 2010
Posts: 24
JoeRCruso is on a distinguished road
Question

Quote:
Originally Posted by iphone_bharat View Post
Ok so fair enough is the error that u cant use this multiple times, lets go to why?? and then I will give u the solution.
are u familiar with 'C' language....so have u heard like one function declaration and two definitions of that function...NO isn't it...same is the case here...
this function tells what to do when a button on action sheet is clicked
no how it will allow u to define that thing at two different place...

so now lets come to the solution...as u said u have more than one action sheets so give them different names and inside this function give condition on which action sheet the button is clicked for eg below:-

Code:
UIActionSheet *actionSheet1;
UIActionSheet *actionSheet2;
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
if(actionSheet==actionSheet1)
{
do this}
else
if(actionSheet==actionSheet2)
{do that}
}
And for avoiding smileys enclose ur code in <CODE> tags as I have done above
Well, I tried this out. And I don't know if I did it right (and I'm pretty sure I didn't) because it isn't working. There are no errors, but when I run the application, the buttons on the action sheets don't work. Again, I'm new to coding, so I probably made some stupid mistake. Here's my code:

Code:
- (IBAction)actionSheetAdd {
	
	UIActionSheet *actionSheet1 = [[UIActionSheet alloc] initWithTitle:@"Choose An Element To Add" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"1", @"2", @"3", nil];
	[actionSheet1 showInView:self.view];
	[actionSheet1 release];
	
}

- (IBAction)doneEditButton{
	
	UIActionSheet *actionSheet2 = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Save", @"Exit", nil];
	[actionSheet2 showInView:self.view];
	[actionSheet2 release];
	
}

UIActionSheet *actionSheet1;
UIActionSheet *actionSheet2;

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
	
	if (actionSheet == actionSheet1) {
		
		if (buttonIndex == 2) {
	
		[self presentModalViewController:threeView animated:YES];
		
		}
		
	}
	
		if(actionSheet == actionSheet2) {
			
			if (buttonIndex == 0) {
			
			[self presentModalViewController:saveView animated:YES];
				
			}
				
		}
}
As you might be able to tell, the code isn't complete yet. But it still doesn't work. Can you somehow tell me what to change?

P.S.: I really need that book :P
JoeRCruso is offline   Reply With Quote
Old 10-18-2010, 11:38 PM   #5 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 108
iphone_bharat is on a distinguished road
Default

i know I am late to reply..but still if u r stuck...tell me exactly what do u want to do..what are these IBActions for...and what is the error that u got in ur code...and then i can give u exact solution..or better if u want tell me ur skype id (if u r on skype) ... and we can discuss ur problem there
iphone_bharat is offline   Reply With Quote
Old 10-19-2010, 07:03 PM   #6 (permalink)
Mobile Apps Developer
 
JoeRCruso's Avatar
 
Join Date: Oct 2010
Posts: 24
JoeRCruso is on a distinguished road
Default

Quote:
Originally Posted by iphone_bharat View Post
i know I am late to reply..but still if u r stuck...tell me exactly what do u want to do..what are these IBActions for...and what is the error that u got in ur code...and then i can give u exact solution..or better if u want tell me ur skype id (if u r on skype) ... and we can discuss ur problem there
That Skype idea is cool. But what kind of Skyping? Chat or call? Mine is joecruso51.
JoeRCruso is offline   Reply With Quote
Old 10-19-2010, 10:15 PM   #7 (permalink)
Banned
 
Join Date: May 2010
Location: New Jersey
Posts: 595
Chessin is on a distinguished road
Send a message via AIM to Chessin
Default

Quote:
Originally Posted by iphone_bharat View Post
Ok so fair enough is the error that u cant use this multiple times, lets go to why?? and then I will give u the solution.
are u familiar with 'C' language....so have u heard like one function declaration and two definitions of that function...NO isn't it...same is the case here...
this function tells what to do when a button on action sheet is clicked
no how it will allow u to define that thing at two different place...

so now lets come to the solution...as u said u have more than one action sheets so give them different names and inside this function give condition on which action sheet the button is clicked for eg below:-

Code:
UIActionSheet *actionSheet1;
UIActionSheet *actionSheet2;
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
if(actionSheet==actionSheet1)
{
do this}
else
if(actionSheet==actionSheet2)
{do that}
}
And for avoiding smileys enclose ur code in <CODE> tags as I have done above
Hey, that code is great for multiple action sheets but how do I a action to each of the button in each action sheet, in this method I only see a way to add a action to 1 button on each sheet
Chessin is offline   Reply With Quote
Reply

Bookmarks

Tags
action, error, multiple, sheet, uiactionsheet

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 348
10 members and 338 guests
alexP, gordo26, headkaze, mistergreen2011, nobstudio, Objective Zero, rayjeong, revg, Sloshmonster, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,655
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, pungs
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 11:14 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0