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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.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 02-23-2010, 05:05 PM   #1 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 83
Default setting a view's tag

How can I go about tagging views so that I can retrieve an array of the views for a certain criteria.

I would like to group views the same way you do so in html with the class attribute.

I know there's a

[obj setTag:];

But this is meant to be unique and I can't get an array of the objects i tag by using viewWithTag:
djp_phillips is offline   Reply With Quote
Old 02-23-2010, 05:26 PM   #2 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,129
Default

They don't have to be unique. The issue is that viewWithTag will return only a single view. So you're going to have to approach it in a way that can get you all of the views - subviews - then iterate through and do whatever you want based on the tag.
__________________
BriTer Ideas LLC - Code review, consulting, development. PM for pricing.

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

Are you a newbie? Things you should read:
BrianSlick is offline   Reply With Quote
Old 02-23-2010, 05:35 PM   #3 (permalink)
Registered Member
 
Join Date: May 2009
Location: Denver CO
Posts: 88
Default

Code:
for(UIView *daView in self.view.subviews){
  if(daView.tag==102021){
    //do stuff
  }
}
Views have a standard array property called subviews. If you iterate through that array, and look for a match on the tag, this should work fine.
NOTE - the code above is an example, and a stepping stone. It's not gonna work if you just copy and paste.
seriessix is offline   Reply With Quote
Old 02-23-2010, 06:19 PM   #4 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,886
Default

Ignore this.
harrytheshark is offline   Reply With Quote
Reply

Bookmarks

Tags
class, group, tag, view

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: 255
23 members and 232 guests
@sandris, ADY, Dani77, diyora, FAED, fredidf, F_Bryant, HDshot, iDifferent, JamesCahall, JasonR, mer10, Oral B, prchn4christ, Rudy, smithdale87, Speed, spiderguy84, stekki, tgjorgoski, Touchmint, twerner, vigu360
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,880
Threads: 89,228
Posts: 380,754
Top Poster: BrianSlick (7,129)
Welcome to our newest member, @sandris
Powered by vBadvanced CMPS v3.1.0

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