Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

shahzadmajeed

macrumors newbie
Original poster
Dec 10, 2010
1
0
Apple says that we can extend an existing class using categories.I think compiler embeds the category code into the existing class.I have accessed a private variable of Employee class (written by myself) using categories.But when i tried to _updateCount of UITableViewCell class of UIKit.h i couldn't access it.

Below is my code

//Category .h file

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface UITableView(UITableViewAdditions)
-(NSInteger) revealSecret;
-(void) changeSecret: (NSInteger) newSecret;
@end

//Category .m file

#import "UITableView+Additions.h"


@implementation UITableView(UITableViewAdditions)

-(NSInteger) revealSecret {
return _updateCount;
}
-(void) changeSecret: (NSInteger) newSecret {
_updateCount = newSecret;
}
@end


//Below is an error it giving me

Ld build/Debug-iphonesimulator/UIWebView.app/UIWebView normal i386
cd "/Volumes/Storage/iMac Data/Use Full Code/UIWebView"
setenv MACOSX_DEPLOYMENT_TARGET 10.5
setenv PATH "/Developer4/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer4/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer4/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -isysroot /Developer4/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.2.sdk "-L/Volumes/Storage/iMac Data/Use Full Code/UIWebView/build/Debug-iphonesimulator" "-F/Volumes/Storage/iMac Data/Use Full Code/UIWebView/build/Debug-iphonesimulator" -filelist "/Volumes/Storage/iMac Data/Use Full Code/UIWebView/build/UIWebView.build/Debug-iphonesimulator/UIWebView.build/Objects-normal/i386/UIWebView.LinkFileList" -mmacosx-version-min=10.5 -Xlinker -objc_abi_version -Xlinker 2 -framework Foundation -framework UIKit -framework CoreGraphics -o "/Volumes/Storage/iMac Data/Use Full Code/UIWebView/build/Debug-iphonesimulator/UIWebView.app/UIWebView"

Undefined symbols:
*"_OBJC_IVAR_$_UITableView._updateCount", referenced from:
* * *_OBJC_IVAR_$_UITableView._updateCount$non_lazy_pt r in UITableView+Additions.o
* * (maybe you meant: _OBJC_IVAR_$_UITableView._updateCount$non_lazy_ptr )
ld: symbol(s) not found
collect2: ld returned 1 exit status



Please someone help how can i solve this problem ?Can i really access a private variable within a precompiled framework ? Should i make a property for it in Category.Should i use Extensions instead ?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.