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-05-2011, 05:18 PM   #1 (permalink)
learning while doing
 
Moe2392's Avatar
 
Join Date: Aug 2011
Location: Ontario
Posts: 31
Moe2392 is on a distinguished road
Default UIBarButtonItem not calling method

//trying to make clear Data Button
UIBarButtonItem *clearData = [[UIBarButtonItem alloc] initWithTitle:@"Clear Data" style:UIBarButtonItemStylePlain target:nil action:@selector(clearValues];
self.navigationItem.rightBarButtonItem = clearData;
[clearData release];

I'm trying to call my "clearValues" method. Why would it not be calling it from here?
Moe2392 is offline   Reply With Quote
Old 09-05-2011, 05:31 PM   #2 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

Code:
target:nil
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 09-05-2011, 06:50 PM   #3 (permalink)
Registered Member
 
Objective Zero's Avatar
 
Join Date: Oct 2010
Posts: 1,210
Objective Zero is on a distinguished road
Default

Yep, do: target:self
If your delegate method is in the same view controller.
__________________
Questions?

Check out my OCR app!
http://itunes.apple.com/app/ocr-pro/id486512712?mt=8
Objective Zero is offline   Reply With Quote
Old 09-05-2011, 07:32 PM   #4 (permalink)
learning while doing
 
Moe2392's Avatar
 
Join Date: Aug 2011
Location: Ontario
Posts: 31
Moe2392 is on a distinguished road
Default

Yes i should have mention that i tried that....(taken a few seconds to retry).... and now it is working properly. Must have had another mistake before, changed from self to nil, fixed the mistake, then left it at nil.........Thanks very much guys

EDIT: If anyone was wondering, you can only target self when a method is within the class that where the other method is that you are targeting. That was my mistake, I had it in a different class calling self to try to reach the other class. Watch you targets.

Last edited by Moe2392; 09-05-2011 at 08:27 PM.
Moe2392 is offline   Reply With Quote
Old 01-30-2012, 12:09 AM   #5 (permalink)
Registered Member
 
Join Date: Jan 2012
Posts: 12
Vineesh is on a distinguished road
Default

Quote:
Originally Posted by Moe2392 View Post
//trying to make clear Data Button
UIBarButtonItem *clearData = [[UIBarButtonItem alloc] initWithTitle:@"Clear Data" style:UIBarButtonItemStylePlain target:nil action:@selector(clearValues];
self.navigationItem.rightBarButtonItem = clearData;
[clearData release];

I'm trying to call my "clearValues" method. Why would it not be calling it from here?
Try this,
UIBarButtonItem *clearData = [[UIBarButtonItem alloc] initWithTitle:@"Clear Data" style:UIBarButtonItemStylePlain target:self action:@selector(clearValues];
Vineesh 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: 381
7 members and 374 guests
apatsufas, JackReidy, jeroenkeij, Sami Gh, tim0504, yomo710
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,671
Threads: 94,121
Posts: 402,903
Top Poster: BrianSlick (7,990)
Welcome to our newest member, JackReidy
Powered by vBadvanced CMPS v3.1.0

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