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 09-12-2010, 01:34 PM   #1 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 71
Coolio098 is on a distinguished road
Default IBAction not returning?

Hey everyone!

Here I have the following code for a button:

Code:
- (IBAction)courseNameConfirm:(id)sender {
	arrayCount = arrayPosition;
	id object1 = [courseData objectAtIndex:arrayCount];
	
	for (int i = 0; i < 100; i++) {
		if ([[object1 objectAtIndex:i] isEqualToString:@""]) {
			[object1 insertObject:courseNameField.text atIndex:i];
			break;
		}
	}

	return courseData;
	
	[self.tableView reloadData];
	
	[gradeSummaryNavigation dismissModalViewControllerAnimated:YES];
	
}
The mutablearray "courseData" is declared in the header file. The issue comes in where courseData returns nil when I try to use it anywhere else in the .m file but everything works fine within this function. Any idea?
Coolio098 is offline   Reply With Quote
Old 09-12-2010, 02:12 PM   #2 (permalink)
Pro. Game Developer
iPhone Dev SDK Supporter
 
Join Date: Feb 2009
Location: żLa Islas Hermosas?
Posts: 2,176
Kalimba is on a distinguished road
Default

"IBAction" methods don't return anything. The symbol IBAction is actually converted to "void" by the preprocessor.

Quote:
Originally Posted by Coolio098 View Post
Hey everyone!

Here I have the following code for a button:

Code:
- (IBAction)courseNameConfirm:(id)sender {
	arrayCount = arrayPosition;
	id object1 = [courseData objectAtIndex:arrayCount];
	
	for (int i = 0; i < 100; i++) {
		if ([[object1 objectAtIndex:i] isEqualToString:@""]) {
			[object1 insertObject:courseNameField.text atIndex:i];
			break;
		}
	}

	return courseData;
	
	[self.tableView reloadData];
	
	[gradeSummaryNavigation dismissModalViewControllerAnimated:YES];
	
}
The mutablearray "courseData" is declared in the header file. The issue comes in where courseData returns nil when I try to use it anywhere else in the .m file but everything works fine within this function. Any idea?
__________________
~~ Word Flurry ~~ App Store / Website / Facebook
Kalimba is offline   Reply With Quote
Old 09-12-2010, 03:15 PM   #3 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 71
Coolio098 is on a distinguished road
Default

How would I be able to access my array in a different part of the .m file?
Coolio098 is offline   Reply With Quote
Old 09-12-2010, 06:22 PM   #4 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 71
Coolio098 is on a distinguished road
Default

Disregard the call view question I found out how to do it. Now here is where I am extremely confused. I have the following code:

Code:
- (void)viewWillAppear:(BOOL)animated {
	[super viewWillAppear:YES];

	if (courseCount == 0) {
		courseCount++;
	}
	else {
		[self courseDataAdd];
		NSLog(@"%@", [courseData objectAtIndex:0]);

	}
}
Code:
- (IBAction)courseNameConfirm:(id)sender {
	
	[self courseDataAdd];
	
	[self.tableView reloadData];

	[gradeSummaryNavigation dismissModalViewControllerAnimated:YES];
	
}
Code:
- (void)courseDataAdd {
	
	arrayCount = arrayPosition;
	id object1 = [courseData objectAtIndex:arrayCount];
	
	for (int i = 0; i < 100; i++) {
		if ([[object1 objectAtIndex:i] isEqualToString:@""]) {
			[object1 insertObject:courseNameField.text atIndex:i];
			break;
		}
	}
	[self.tableView reloadData];
}
Now when I press my button for the courseNameConfirm method, it calls the courseDataAdd method with no problems and it displays the values on my table. However, when I try to call the same courseDataAdd method in viewWillAppear, it returns the value of my array as (null). Could this be due to a presentModalViewController? If not, what are some of your thoughts? Any help would be greatly appreciated!
Coolio098 is offline   Reply With Quote
Reply

Bookmarks

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: 344
10 members and 334 guests
cgokey, givensur, iGamesDev, jenniead38, linkmx, mraalex, PixelInteractive, raihan.zbr, Trickphotostudios
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

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