Cyrus Bastankhah
Cyrus Bastankhah

Reputation: 5

How to assign a Url to a PSButtonCell action

Hi guys I have been working on this tweak an for the most part I'm done. The only thing that I have left in mind is to add a donate button to my preference bundle. I have already created a cell with a label and action, I just need to know how to assign a url to the action and where I need to put the assign code in. Do I put it in my tweak.xm? In a separate plist? Please help, and thanks a lot.

Upvotes: 0

Views: 564

Answers (1)

guoc
guoc

Reputation: 414

You can implement your action in a separate file in your setting bundle. it'd better use preference_bundle template provided by theos. About URL, you can have a look at NotiQuiet's code for an example. I have test the method openURL, it still works although this file was written 8 months ago.

In Resources/NotiQuiet.plist, the action is declared:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>items</key>
    <array>
        <!-- Irrelevant cells omitted -->
        <dict>
            <key>action</key>
            <string>followOnTwitter</string>
            <key>cell</key>
            <string>PSLinkCell</string>
            <key>icon</key>
            <string>Twitter.png</string>
            <key>label</key>
            <string>PREFS_TWITTER</string>
        </dict>
    </array>
    <key>title</key>
    <string>NotiQuiet</string>
</dict>
</plist>

In ADNQListController.m, the method is implemented:


- (void)followOnTwitter {
    if ([[UIApplication sharedApplication]canOpenURL:[NSURL URLWithString:@"tweetbot:"]]) {
        [[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"tweetbot:///user_profile/thekirbylover"]];
    } else if ([[UIApplication sharedApplication]canOpenURL:[NSURL URLWithString:@"tweetings:"]]) {
        [[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"tweetings:///user?screen_name=thekirbylover"]];
    } else if ([[UIApplication sharedApplication]canOpenURL:[NSURL URLWithString:@"twitter:"]]) {
        [[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"twitter://user?screen_name=thekirbylover"]];
    } else {
        [[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"http://twitter.com/intent/follow?screen_name=thekirbylover"]];
    }
}

For details, https://theapplewiki.com/wiki/Dev:Preferences_specifier_plist is always helpful.

Upvotes: 0

Related Questions