简体   繁体   中英

Accessing a readonly property

I have found this property in an header file:

@property(readonly) UIImage *wallpaperImage;

but, as you can see it is readonly . I have read about class extensions, so in my main tweak file I have written this:

@interface SBFWallpaperView ()

@property(readwrite) UIImage *wallpaperImage;

@end

But it doesn't work. As I try to use [obj setWallpaperImage:image]; SpringBoard dies. What should I do? I also cannot find a valid instance variable to hook with MSHookIvar, so I'm really clueless of what to do. Thanks in advance if you can help me!

Also, I should specify: obj is an object of type SBFWallpaperView , which I got by MSHooking a SBFWallpaperView ivar.

If the property is marked readonly in a header, you should change it to not be readonly in the header. If you don't own the header, there isn't much you can do. Without more context, it's hard to advise you on a work-around, but consider something like creating a new instance of SBFWallpaperView ? Perhaps it has an initWithImage: method?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM