1

It's Julian Again. In my project I have around 50 different urls and i need to group them into two groups. So that 25 of them are displayed in VC one and the rest in VC2. I wanted to add a tag, and then based on this tag distinguish the two groups but I don't know how to do that. So that it looks like that:

NSURL tag:@"a"

and then

if(tag == "a")
{// Do the code}

How could I do that Thanks in advance!

MANOJ GOPI
  • 1,279
  • 10
  • 31
Julian E.
  • 4,687
  • 6
  • 32
  • 49
  • What you mean by tag ? From where do you get those urls ? On what basis you need to set the tag in your code ? – Midhun MP Jan 31 '15 at 11:11
  • Okay. to be precise, all of them are links to url's. I have to display some in Portrait and some in landscape. That's why i have to distinguish them. – Julian E. Jan 31 '15 at 11:13
  • 1
    My question is how you are identifying which all are used to be in portrait and which all are used in landscape ? From where you get that information (if you need to add tag also, you need that information right ?) – Midhun MP Jan 31 '15 at 11:21

2 Answers2

1

You can either using NSDictionary or NSObject to store your URL instance and the associated tag value. I would prefer using NSObject:

Create a subclass of NSObject called MyNSURLObject.

For MyNSURLObject.h: (you don't need to modify MyNSURLObject.m file)

#import <Foundation/Foundation.h>

@interface MyNSURLObject : NSObject
@property(strong, nonatomic) NSURL *myURL;
@property(strong, nonatomic) NSString *myTag;
@end

Create an instance of MyNSURLObject whenever you need to store an URL, ex:

MyNSURLObject *myNSURLObject = [[MyNSURLObject alloc] init];
myNSURLObject.myURL = whateverurl;
myNSURLObject.myTag = @"a"; // or @"b"
user523234
  • 14,323
  • 10
  • 62
  • 102
0

You can add 25 urls in one array (Swift Array or Objective-C NSMutableArray) and 25 in another. Arrays allow you to group 'values' in unique containers.

Then pass the first array to the first view controller and same with the second array.

Nicolas B.
  • 1,318
  • 1
  • 11
  • 20