SORU
22 EKİM 2010, Cuma


Nasıl NSMutableArray veya başka bir kap içinde bir NSRange mağaza?

Yapmak istediğim şey şu:

NSRange r = NSMakeRange(0,5);
id a = [NSMutableArray a];
[a addObject: r]; // but NSRange is not a NSObject *

Boole ile birlikte, bu gibi bir kod kullanmak istiyorum:

[a addObject: [NSNumber numberWithBool: YES]];

ya da bir tamsayı:

[a addObject: [NSNumber numberWithInteger: 3]];

NSRange ile eşdeğer nedir? Gerçekten yapmak istemiyorum ne bu başarmak için NSObject kendi alt oluşturun. Kesinlikle ne ile Apple zaten sağlanan bir yolu var mı?

CEVAP
22 EKİM 2010, Cuma


Use NSValue's valueWithRange:.

[a addObject:[NSValue valueWithRange:r]];
...

NSRange r = [[a objectAtIndex:4] rangeValue];

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • ethr95awd

    ethr95awd

    8 Kasım 2006
  • tunez4you

    tunez4you

    20 EKİM 2008
  • Watcher3223

    Watcher3223

    15 Kasım 2007