本文整理汇总了C#中NSDictionary.ObjectForKey方法的典型用法代码示例。如果您正苦于以下问题:C# NSDictionary.ObjectForKey方法的具体用法?C# NSDictionary.ObjectForKey怎么用?C# NSDictionary.ObjectForKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NSDictionary
的用法示例。
在下文中一共展示了NSDictionary.ObjectForKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StatusUpdated
// In the status dictionary:
// "FoundBarcodes" key is a NSSet of all discovered barcodes this scan session
// "NewFoundBarcodes" is a NSSet of barcodes discovered in the most recent pass.
// When a barcode is found, it is added to both sets. The NewFoundBarcodes
// set is cleaned out each pass.
// "Guidance" can be used to help guide the user through the process of discovering
// a long barcode in sections. Currently only works for Code 39.
// "Valid" is TRUE once there are valid barcode results.
// "InRange" is TRUE if there's currently a barcode detected the viewfinder. The barcode
// may not have been decoded yet.
public override void StatusUpdated(BarcodePickerController picker, NSDictionary status)
{
NSNumber isValid = (NSNumber) status.ObjectForKey (new NSString ("Valid"));
NSNumber inRange = (NSNumber) status.ObjectForKey (new NSString ("InRange"));
SetArrows (inRange.BoolValue, true);
if (isValid.BoolValue)
{
BeepOrVibrate ();
ParentPicker.DoneScanning ();
}
NSNumber guidanceLevel = (NSNumber) status.ObjectForKey (new NSString ("Guidance"));
if (guidanceLevel != null)
{
if (guidanceLevel.IntValue == 1)
{
textCue.Text = "Try moving the camera close to each part of the barcode";
}
else if (guidanceLevel.IntValue == 2)
{
textCue.Text = (NSString) status.ObjectForKey (new NSString ("PartialBarcode"));
}
else
{
textCue.Text = "";
}
}
}
示例2: PhotoWithDictionary
public static Photo PhotoWithDictionary (NSDictionary dictionary)
{
return new Photo {
ImageName = (NSString)dictionary.ObjectForKey (new NSString ("imageName")),
Comment = (NSString)dictionary.ObjectForKey (new NSString ("comment")),
Rating = ((NSNumber)dictionary.ObjectForKey (new NSString ("rating"))).Int32Value,
};
}
示例3: HandleResult
public override void HandleResult(FBRequest request, NSDictionary dict)
{
if (dict.ObjectForKey(new NSString("owner")) != null)
{
}
else
{
NSObject id = dict.ObjectForKey(new NSString("id"));
_facebookController.LoggedIn(id.ToString());
}
}
示例4: HandleResult
public override void HandleResult(FBRequest request, NSDictionary dict)
{
if (dict.ObjectForKey(new NSString("owner")) != null)
{
}
else
{
NSObject id = dict.ObjectForKey(new NSString("id"));
_controller.GetPIDforPhotoFBID(id.ToString(), AutoTag);
}
}
示例5: Awake
public virtual void Awake(NSArray rootObjects, IBObjectContainer objects, NSDictionary context)
{
NSEnumerator en;
id obj;
NSMutableArray topLevelObjects = (NSMutableArray)context.ObjectForKey((id)NS.NibTopLevelObjects);
id owner = context.ObjectForKey(NS.NibOwner);
id first = null;
id app = null;
// Get the file's owner and NSApplication object references...
if (((NSCustomObject)rootObjects.ObjectAtIndex(1)).ClassName.IsEqualToString(@"FirstResponder"))
first = ((NSCustomObject)rootObjects.ObjectAtIndex(1)).RealObject;
else
NS.Log(@"%s:first responder missing\n", "Awake");
if (((NSCustomObject)rootObjects.ObjectAtIndex(2)).ClassName.IsEqualToString(@"NSApplication"))
app = ((NSCustomObject)rootObjects.ObjectAtIndex(2)).RealObject;
else
NS.Log(@"%s:NSApplication missing\n", "Awake");
// Use the owner as first root object
((NSCustomObject)rootObjects.ObjectAtIndex(0)).SetRealObject(owner);
en = rootObjects.ObjectEnumerator();
while ((obj = en.NextObject()) != null)
{
if (obj.RespondsToSelector(new SEL("NibInstantiate")))
{
obj = (id)Objc.MsgSend(obj, "NibInstantiate", null);
}
// IGNORE file's owner, first responder and NSApplication instances...
if ((obj != null) && (obj != owner) && (obj != first) && (obj != app))
{
topLevelObjects.AddObject(obj);
// All top level objects must be released by the caller to avoid
// leaking, unless they are going to be released by other nib
// objects on behalf of the owner.
//RETAIN(obj);
}
//FIXME
//if ((obj.IsKindOfClass(NSMenu.Class)) &&
// (((NSMenu)obj _isMainMenu]))
// {
// // add the menu...
// NSApp._setMainMenu(obj);
// }
}
// Load connections and awaken objects
Objc.MsgSend(objects, "NibInstantiate", null);
}
示例6: ConversationWithDictionary
public static Conversation ConversationWithDictionary (NSDictionary dictionary)
{
var photoValues = (NSArray)dictionary.ObjectForKey (new NSString ("photos"));
var photos = new NSMutableArray (photoValues.Count);
for (nint i = 0; i < (nint)photoValues.Count; i++) {
var photo = Photo.PhotoWithDictionary (photoValues.GetItem <NSDictionary> (i));
photos.Add (photo);
}
return new Conversation {
Name = (NSString)dictionary.ObjectForKey (new NSString ("name")),
Photos = photos
};
}
示例7: DidReceiveRemoteNotification
/*
[Export("application:didReceiveRemoteNotification:fetchCompletionHandler:")]
public void DidReceiveRemoteNotification (UIApplication application, NSDictionary userInfo, Action<UIBackgroundFetchResult> completionHandler) {
// This method is part of iOS 7.0 new remote notification support.
// This method is invoked if your Entitlements list the "remote-notification" background operation is set, and you receive a remote notification.
// Upon completion, you must notify the operating system of the result of the method by invoking the provided callback.
// Important: failure to call the provided callback method with the result code before this method completes will cause your application to be terminated.
log ("DidReceiveRemoteNotification: processing data..." );
processNotification(userInfo, false, application.ApplicationState);
}
*/
/// <summary>
/// Processes the notification.
/// </summary>
/// <param name="options">Options.</param>
/// <param name="fromFinishedLaunching">True if this method comes from the 'FinishedLaunching' delegated method</param>
/// <param name="applicationState">The application state that received the remote notification</param>
public static void processNotification(NSDictionary options, bool fromFinishedLaunching, UIApplicationState applicationState)
{
try {
#if DEBUG
log ("******* Checking for PUSH NOTIFICATION data in launch options - fromFinishedLaunching="+fromFinishedLaunching+". application state: "+ applicationState);
#endif
if (options != null) {
if (fromFinishedLaunching) {
NSDictionary remoteNotif = (NSDictionary)options.ObjectForKey (UIApplication.LaunchOptionsRemoteNotificationKey);
ProcessRemoteNotification (remoteNotif, fromFinishedLaunching, applicationState);
} else {
ProcessRemoteNotification (options, fromFinishedLaunching, applicationState);
}
} else {
#if DEBUG
log ("******* NO launch options");
#endif
}
} catch (System.Exception ex) {
#if DEBUG
log ("******* Unhandled exception when trying to process notification. fromFinishedLaunching[" + fromFinishedLaunching + "]. Exception message: " + ex.Message);
#endif
}
}
示例8: FinishedLaunching
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
{
ServiceLocator.Instance.Add<IDatabase, Database>();
Globe.SharedInstance.Database.InitializeDatabase();
int userid = (int)NSUserDefaults.StandardUserDefaults.IntForKey("iduser");
string username = NSUserDefaults.StandardUserDefaults.StringForKey("username");
string password = NSUserDefaults.StandardUserDefaults.StringForKey("password");
if (!String.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password) && userid != 0)
{
Globe.SharedInstance.User.username = username;
Globe.SharedInstance.User.password = password;
Globe.SharedInstance.User.idUser = userid;
createTabBarController();
Window.RootViewController = TabBarController;
Window.MakeKeyAndVisible();
}
SDImageCache.SharedImageCache.ClearMemory();
SDImageCache.SharedImageCache.ClearDisk();
StartTickNotification();
if (launchOptions != null && launchOptions.ObjectForKey(UIApplication.LaunchOptionsRemoteNotificationKey) != null && TabBarController != null)
{
TabBarController.SelectedIndex = 1;
}
return true;
}
示例9: AppDelegate
public AppDelegate ()
{
PrepareCache ();
ExtractImages ();
controller = new MonodocDocumentController ();
// Some UI feature we use rely on Lion, so special case it
try {
var version = new NSDictionary ("/System/Library/CoreServices/SystemVersion.plist");
isOnLion = version.ObjectForKey (new NSString ("ProductVersion")).ToString ().StartsWith ("10.7");
} catch {}
// Load documentation
Root = RootTree.LoadTree (null);
var macDocPath = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData), "macdoc");
if (!Directory.Exists (macDocPath))
Directory.CreateDirectory (macDocPath);
IndexUpdateManager = new IndexUpdateManager (Root.HelpSources.Cast<HelpSource> ().Select (hs => Path.Combine (hs.BaseFilePath, hs.Name + ".zip")).Where (File.Exists),
macDocPath);
BookmarkManager = new BookmarkManager (macDocPath);
AppleDocHandler = new AppleDocHandler ("/Library/Frameworks/Mono.framework/Versions/Current/etc/");
// Configure the documentation rendering.
SettingsHandler.Settings.EnableEditing = false;
SettingsHandler.Settings.preferred_font_size = 200;
HelpSource.use_css = true;
}
示例10: ReceivedRemoteNotification
public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo)
{
var aps = userInfo.ObjectForKey (new NSString ("aps")) as NSDictionary;
var alert = aps.ObjectForKey (new NSString ("alert")).ToString ();
var av = new UIAlertView ("推播通知", alert, null, "確定", null);
av.Show ();
}
示例11: ProcessNotification
public static void ProcessNotification (NSDictionary options, bool fromFinishedLaunching)
{
//Check to see if the dictionary has the aps key. This is the notification payload you would have sent
if (options.ContainsKey (new NSString (Resources.Communication.ApsRootElement))) {
//Get the aps dictionary
var aps = options.ObjectForKey (new NSString (Resources.Communication.ApsRootElement)) as NSDictionary;
string alert = string.Empty;
string sound = string.Empty;
int badge = -1;
//Extract the alert text
//NOTE: If you're using the simple alert by just specifying " aps:{alert:"alert msg here"} "
// this will work fine. But if you're using a complex alert with Localization keys, etc., your "alert" object from the aps dictionary
// will be another NSDictionary... Basically the json gets dumped right into a NSDictionary, so keep that in mind
if (aps.ContainsKey (new NSString (Resources.Communication.ApsAlertElement))) {
//alert = (aps [new NSString (Resources.Communication.ApsAlertElement)] as NSString).ToString ();
alert = aps.ObjectForKey (new NSString (Resources.Communication.ApsAlertElement)).ToString ();
}
//Extract the sound string
if (aps.ContainsKey (new NSString (Resources.Communication.ApsSoundElement))) {
//sound = (aps [new NSString (Resources.Communication.ApsSoundElement)] as NSString).ToString ();
sound = aps.ObjectForKey (new NSString (Resources.Communication.ApsSoundElement)).ToString ();
}
//Extract the badge
if (aps.ContainsKey (new NSString (Resources.Communication.ApsBadgeElement))) {
//string badgeStr = (aps [new NSString (Resources.Communication.ApsBadgeElement)] as NSString).ToString ();
string badgeStr = aps.ObjectForKey (new NSString (Resources.Communication.ApsBadgeElement)).ToString ();
int.TryParse (badgeStr, out badge);
}
//If this came from the ReceivedRemoteNotification while the app was running,
// we of course need to manually process things like the sound, badge, and alert.
if (!fromFinishedLaunching) {
//Manually set the badge in case this came from a remote notification sent while the app was open
if (badge >= 0)
UIApplication.SharedApplication.ApplicationIconBadgeNumber = badge;
/*
//Manually play the sound
if (!string.IsNullOrEmpty (sound)) {
//This assumes that in your json payload you sent the sound filename (like sound.caf)
// and that you've included it in your project directory as a Content Build type.
var soundObj = MonoTouch.AudioToolbox.SystemSound.FromFile (sound);
soundObj.PlaySystemSound ();
}
*/
//Manually show an alert
if (!string.IsNullOrEmpty (alert)) {
using (UIAlertView avAlert = new UIAlertView ("Notification", alert, null, "OK", null)) {
avAlert.Show ();
}
}
}
}
}
示例12: ReceivedRemoteNotification
public override void ReceivedRemoteNotification (UIApplication application, NSDictionary userInfo)
{
var message = (NSString) userInfo.ObjectForKey (new NSString ("aps")).ValueForKey(new NSString("alert"));
var alert = new UIAlertView("Notification", message, null, "Okay", null);
alert.Show ();
}
示例13: HandleResult
public override void HandleResult(FBRequest request, NSDictionary dict)
{
if (dict.ObjectForKey(new NSString("owner")) != null)
{
}
else
{
NSObject id = dict.ObjectForKey(new NSString("pid"));
if(IsWallPhoto)
{
_controller.TagPhoto(id.ToString());
}
else
{
_controller.SetProfilePicture(id.ToString());
}
}
}
示例14: AppDelegate
public AppDelegate ()
{
PrepareCache ();
ExtractImages ();
controller = new MonodocDocumentController ();
// Some UI feature we use rely on Lion or better, so special case it
try {
var version = new NSDictionary ("/System/Library/CoreServices/SystemVersion.plist");
var osxVersion = Version.Parse (version.ObjectForKey (new NSString ("ProductVersion")).ToString ());
isOnLion = osxVersion.Major == 10 && osxVersion.Minor >= 7;
} catch {}
// Load documentation
var args = Environment.GetCommandLineArgs ();
IEnumerable<string> extraDocs = null, extraUncompiledDocs = null;
if (args != null && args.Length > 1) {
var extraDirs = args.Skip (1);
extraDocs = extraDirs
.Where (d => d.StartsWith ("+"))
.Select (d => d.Substring (1))
.Where (d => Directory.Exists (d));
extraUncompiledDocs = extraDirs
.Where (d => d.StartsWith ("@"))
.Select (d => d.Substring (1))
.Where (d => Directory.Exists (d));
}
if (extraUncompiledDocs != null)
foreach (var dir in extraUncompiledDocs)
RootTree.UncompiledHelpSources.Add (dir);
Root = RootTree.LoadTree (null);
if (extraDocs != null)
foreach (var dir in extraDocs)
Root.AddSource (dir);
var macDocPath = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData), "macdoc");
if (!Directory.Exists (macDocPath))
Directory.CreateDirectory (macDocPath);
var helpSources = Root.HelpSources
.Cast<HelpSource> ()
.Where (hs => !string.IsNullOrEmpty (hs.BaseFilePath) && !string.IsNullOrEmpty (hs.Name))
.Select (hs => Path.Combine (hs.BaseFilePath, hs.Name + ".zip"))
.Where (File.Exists);
IndexUpdateManager = new IndexUpdateManager (helpSources,
macDocPath);
BookmarkManager = new BookmarkManager (macDocPath);
AppleDocHandler = new AppleDocHandler ("/Library/Frameworks/Mono.framework/Versions/Current/etc/");
// Configure the documentation rendering.
SettingsHandler.Settings.EnableEditing = false;
SettingsHandler.Settings.preferred_font_size = 200;
HelpSource.use_css = true;
}
示例15: FinishedPickingMedia
public override void FinishedPickingMedia(UIImagePickerController picker, NSDictionary info)
{
UIImage image = (UIImage)info.ObjectForKey(new NSString("UIImagePickerControllerOriginalImage"));
// do whatever else you'd like to with the image
Console.WriteLine("media {0} x {1}", image.CGImage.Width, image.CGImage.Height);
picker.DismissModalViewControllerAnimated(true);
_imageView.Image = image;
if (_popover != null && _popover.PopoverVisible)
_popover.Dismiss(true);
}