Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
332 views
in Technique[技术] by (71.8m points)

iphone - Using Private Framework: Importing RadioPreferences.h

I'm following the selected answer importing private frameworks in Xcode

Basically I want to be able to control Airplane mode in my app. When I import RadioPreferences.h into my app and try to compile, I'm getting Expected Identifier for @class <RadiosPreferencesDelegate>;

I'm not exactly sure what to do next. I didn't even know you can forward declare protocols.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

First copy the following contents into a file named RadioPreferences.h. (Taken from https://stackoverflow.com/a/13095362/418715 ).

@protocol RadiosPreferencesDelegate
-(void)airplaneModeChanged;
@end


@interface RadiosPreferences : NSObject
{
    struct __SCPreferences *_prefs;
    int _applySkipCount;
    id <RadiosPreferencesDelegate> _delegate;
    BOOL _isCachedAirplaneModeValid;
    BOOL _cachedAirplaneMode;
    BOOL notifyForExternalChangeOnly;
}

- (id)init;
- (void)dealloc;
@property(nonatomic) BOOL airplaneMode;
- (void)refresh;
- (void)initializeSCPrefs:(id)arg1;
- (void)notifyTarget:(unsigned int)arg1;
- (void)synchronize;
- (void *)getValueForKey:(id)arg1;
- (void)setValue:(void *)arg1 forKey:(id)arg2;
@property(nonatomic) BOOL notifyForExternalChangeOnly; // @synthesize notifyForExternalChangeOnly;
@property(nonatomic) id <RadiosPreferencesDelegate> delegate; // @synthesize delegate=_delegate;

@end

  • Next, go to the Build Phases of your target in Xcode and expand the Link Binary With Libraries section.
  • In a finder window navigate to /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/System/Library/PrivateFrameworks. Replace iPhoneOS6.0.sdk in the path with the sdk you are targeting.
  • Drag AppSupport.framework over to your expanded Link Binary With Libraries section.

Everything should now compile and you will be able to use the class.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...