All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.bugvm.apple.foundation.NSUbiquitousKeyValueStore Maven / Gradle / Ivy

There is a newer version: 1.2.9
Show newest version
/*
 * Copyright (C) 2013-2015 RoboVM AB
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.bugvm.apple.foundation;

/**/
import java.io.*;
import java.nio.*;
import java.util.*;
import com.bugvm.objc.*;
import com.bugvm.objc.annotation.*;
import com.bugvm.objc.block.*;
import com.bugvm.rt.*;
import com.bugvm.rt.annotation.*;
import com.bugvm.rt.bro.*;
import com.bugvm.rt.bro.annotation.*;
import com.bugvm.rt.bro.ptr.*;
import com.bugvm.apple.corefoundation.*;
import com.bugvm.apple.uikit.*;
import com.bugvm.apple.coretext.*;
import com.bugvm.apple.coreanimation.*;
import com.bugvm.apple.coredata.*;
import com.bugvm.apple.coregraphics.*;
import com.bugvm.apple.coremedia.*;
import com.bugvm.apple.security.*;
import com.bugvm.apple.dispatch.*;
/**/

/**/
/**
 * @since Available in iOS 5.0 and later.
 */
/**/
/**/@Library("Foundation") @NativeClass/**/
/**/public/**/ class /**/NSUbiquitousKeyValueStore/**/ 
    extends /**/NSObject/**/ 
    /**//**/ {

    public static class Notifications {
        /**
         * @since Available in iOS 5.0 and later.
         */
        public static NSObject observeDidChangeExternally(NSUbiquitousKeyValueStore object, final VoidBlock3> block) {
            return NSNotificationCenter.getDefaultCenter().addObserver(DidChangeExternallyNotification(), object, NSOperationQueue.getMainQueue(), new VoidBlock1() {
                @Override
                public void invoke(NSNotification a) {
                    String reason = null;
                    List keys = null;
                    NSDictionary data = a.getUserInfo();
                    if (data.containsKey(ChangeReasonKey())) {
                        NSString val = (NSString)data.get(ChangeReasonKey());
                        reason = val.toString();
                    }
                    if (data.containsKey(ChangedKeysKey())) {
                        @SuppressWarnings("unchecked")
                        NSArray val = (NSArray)data.get(ChangedKeysKey());
                        keys = val.asStringList();
                    }
                    block.invoke((NSUbiquitousKeyValueStore)a.getObject(), reason, keys);
                }
            });
        }
    }
    
    /**/public static class NSUbiquitousKeyValueStorePtr extends Ptr {}/**/
    /**/static { ObjCRuntime.bind(NSUbiquitousKeyValueStore.class); }/**/
    /**//**/
    /**/
    public NSUbiquitousKeyValueStore() {}
    protected NSUbiquitousKeyValueStore(SkipInit skipInit) { super(skipInit); }
    /**/
    /**/
    @Property(selector = "dictionaryRepresentation")
    public native NSDictionary asDictionary();
    /**/
    /**//**/
    public void put(String key, NSObject object) {
        setObject(object, key);
    }
    public void put(String key, String string) {
        setString(string, key);
    }
    public void put(String key, NSData data) {
        setData(data, key);
    }
    public void put(String key, NSArray array) {
        setArray(array, key);
    }
    public void put(String key, NSDictionary dictionary) {
        setDictionary(dictionary, key);
    }
    public void put(String key, long value) {
        setLongLong(value, key);
    }
    public void put(String key, double value) {
        setDouble(value, key);
    }
    public void put(String key, boolean value) {
        setBool(value, key);
    }

    public Map asMap() {
        return asDictionary().asStringMap();
    }
    /**/
    /**
     * @since Available in iOS 5.0 and later.
     */
    @GlobalValue(symbol="NSUbiquitousKeyValueStoreDidChangeExternallyNotification", optional=true)
    public static native NSString DidChangeExternallyNotification();
    /**
     * @since Available in iOS 5.0 and later.
     */
    @GlobalValue(symbol="NSUbiquitousKeyValueStoreChangeReasonKey", optional=true)
    protected static native NSString ChangeReasonKey();
    /**
     * @since Available in iOS 5.0 and later.
     */
    @GlobalValue(symbol="NSUbiquitousKeyValueStoreChangedKeysKey", optional=true)
    protected static native NSString ChangedKeysKey();
    
    @Method(selector = "objectForKey:")
    public native NSObject get(String aKey);
    @Method(selector = "setObject:forKey:")
    protected native void setObject(NSObject anObject, String aKey);
    @Method(selector = "removeObjectForKey:")
    public native void remove(String aKey);
    @Method(selector = "stringForKey:")
    public native String getString(String aKey);
    @Method(selector = "arrayForKey:")
    public native NSArray getArray(String aKey);
    @Method(selector = "dictionaryForKey:")
    public native NSDictionary getDictionary(String aKey);
    @Method(selector = "dataForKey:")
    public native NSData getData(String aKey);
    @Method(selector = "longLongForKey:")
    public native long getLong(String aKey);
    @Method(selector = "doubleForKey:")
    public native double getDouble(String aKey);
    @Method(selector = "boolForKey:")
    public native boolean getBoolean(String aKey);
    @Method(selector = "setString:forKey:")
    protected native void setString(String aString, String aKey);
    @Method(selector = "setData:forKey:")
    protected native void setData(NSData aData, String aKey);
    @Method(selector = "setArray:forKey:")
    protected native void setArray(NSArray anArray, String aKey);
    @Method(selector = "setDictionary:forKey:")
    protected native void setDictionary(NSDictionary aDictionary, String aKey);
    @Method(selector = "setLongLong:forKey:")
    protected native void setLongLong(long value, String aKey);
    @Method(selector = "setDouble:forKey:")
    protected native void setDouble(double value, String aKey);
    @Method(selector = "setBool:forKey:")
    protected native void setBool(boolean value, String aKey);
    @Method(selector = "synchronize")
    public native boolean synchronize();
    @Method(selector = "defaultStore")
    public static native NSUbiquitousKeyValueStore getDefaultStore();
    /**/
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy