iOS中為cagetory添加屬性

我們知道 在iOS中cagetory里面只能添加方法 ,如果我們想添加屬性 就要用到

在銀海等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供網(wǎng)站設(shè)計、網(wǎng)站制作 網(wǎng)站設(shè)計制作按需網(wǎng)站制作,公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),高端網(wǎng)站設(shè)計,全網(wǎng)整合營銷推廣,外貿(mào)網(wǎng)站建設(shè),銀海網(wǎng)站建設(shè)費用合理。

<objc/runtime.h>

OBJC_EXPORTvoid objc_setAssociatedObject(idobject,constvoid *key,id value, objc_AssociationPolicy policy)
__OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_1);
OBJC_EXPORTid objc_getAssociatedObject(idobject,constvoid *key)
__OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_1);



例如

@interface UIButton(custom)

@property (nonatomic, copy) NSIndexPath *selectIndexPath;

@end

staticNSIndexPath *k_SelectIndexPath;

@implementation UIButton(custom)

@dynamic selectIndexPath;

- (void)setSelectIndexPath:(NSIndexPath *)selectIndexPath

{

objc_setAssociatedObject(self, &k_SelectIndexPath, selectIndexPath,OBJC_ASSOCIATION_COPY);

}

- (NSIndexPath*)selectIndexPath

{

returnobjc_getAssociatedObject(self, &k_SelectIndexPath);

}

@end

標(biāo)題名稱:iOS中為cagetory添加屬性
本文來源:http://muchs.cn/article36/gesepg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計公司、搜索引擎優(yōu)化、面包屑導(dǎo)航、做網(wǎng)站虛擬主機

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

搜索引擎優(yōu)化