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

  • Fubar Protocol

    Fubar Protoc

    21 AĞUSTOS 2010
  • Michael Zhang

    Michael Zhan

    8 EYLÜL 2012
  • ODN

    ODN

    26 Kasım 2006