• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# NSError类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中NSError的典型用法代码示例。如果您正苦于以下问题:C# NSError类的具体用法?C# NSError怎么用?C# NSError使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



NSError类属于命名空间,在下文中一共展示了NSError类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: HandleFacebookError

		private void HandleFacebookError(NSError error)
		{
			if (FBErrorUtility.ShouldNotifyUser(error))
			{
				string errorText = FBErrorUtility.UserMessage(error);
				UIAlertView alertView = new UIAlertView("APP/ALERT/TITLE/ERROR".Localize(), errorText, null, "APP/ALERT/BUTTON/OK".Localize(), null);
				alertView.Show();
			}
			else
			{
				if (FBErrorUtility.ErrorCategory(error) == FBErrorCategory.UserCancelled)
				{
					Console.WriteLine("Facebook login cancelled by user.");
				}
				else if (FBErrorUtility.ErrorCategory(error) == FBErrorCategory.AuthenticationReopenSession)
				{
					UIAlertView alertView = new UIAlertView("APP/ALERT/TITLE/ERROR".Localize(), "APP/FACEBOOK/ERRORS/RELOGIN".Localize(), null, "APP/ALERT/BUTTON/OK".Localize(), null);
					alertView.Show();
				}
				else
				{
					UIAlertView alertView = new UIAlertView("APP/ALERT/TITLE/ERROR".Localize(), "APP/FACEBOOK/ERRORS/GENERAL".Localize(), null, "APP/ALERT/BUTTON/OK".Localize(), null);
					alertView.Show();
				}
			}
			Interfaces.Instance.FacebookInterface.Close(true);
		}
开发者ID:pavlob0910,项目名称:my-start-stable,代码行数:27,代码来源:LoginViewController.cs


示例2: LoadStockPoints

		public static List<StockDataPoint> LoadStockPoints(int maxItems)
		{
			List<StockDataPoint> stockPoints = new List<StockDataPoint> ();

			string filePath = NSBundle.MainBundle.PathForResource ("AppleStockPrices", "json");
			NSData json = NSData.FromFile (filePath);
			NSError error = new NSError ();
			NSArray data = (NSArray)NSJsonSerialization.Deserialize (json, NSJsonReadingOptions.AllowFragments, out error);
			NSDateFormatter formatter = new NSDateFormatter ();
			formatter.DateFormat = "dd-MM-yyyy";

			for (int i = 0; i < (int)data.Count; i++) {
				if (i == maxItems) {
					break;
				}
				NSDictionary jsonPoint = data.GetItem<NSDictionary> ((nuint)i);
				StockDataPoint dataPoint = new StockDataPoint ();
				dataPoint.DataXValue = formatter.Parse ((NSString)jsonPoint ["date"]);
				dataPoint.Open = (NSNumber)jsonPoint ["open"];
				dataPoint.Low = (NSNumber)jsonPoint ["low"];
				dataPoint.Close = (NSNumber)jsonPoint ["close"];
				dataPoint.Volume = (NSNumber)jsonPoint ["volume"];
				dataPoint.High = (NSNumber)jsonPoint ["high"];
				stockPoints.Add (dataPoint);
			}

			return stockPoints;
		}
开发者ID:tremors,项目名称:ios-sdk,代码行数:28,代码来源:StockDataPoint.cs


示例3: PopulateCalendarList

		/// <summary>
		/// called as the completion handler to requesting access to the calendar
		/// </summary>
		protected void PopulateCalendarList (bool grantedAccess, NSError e)
		{
			// if it err'd show it to the user
			if ( e != null ) {
				Console.WriteLine ( "Err: " + e.ToString () );
				new UIAlertView ( "Error", e.ToString(), null, "ok", null ).Show();
				return;
			}

			// if the user granted access to the calendar data
			if (grantedAccess) {
				// get calendars of the particular type (either events or reminders)
				calendars = App.Current.EventStore.GetCalendars ( entityType );

				// build out an MT.D list of all the calendars, we show the calendar title
				// as well as the source (where the calendar is pulled from, like iCloud, local
				// exchange, etc.)
				calendarListRoot.Add (
					new Section ( ) { 
						from elements in calendars
						select ( Element ) new StringElement ( elements.Title, elements.Source.Title )
					}
				);

				this.InvokeOnMainThread ( () => { this.Root = calendarListRoot; } ); 
			}
			// if the user didn't grant access, show an alert
			else {
				Console.WriteLine ( "Access denied by user. " );
				InvokeOnMainThread ( () => { 
					new UIAlertView ( "No Access", "Access to calendar not granted", null, "ok", null).Show ();
				});
			}
		}
开发者ID:BoogieMAN2K,项目名称:monotouch-samples,代码行数:37,代码来源:CalendarListController.cs


示例4: FoundResults

        private void FoundResults(ParseObject[] array, NSError error)
        {
            var easySection = new Section("Easy");
            var mediumSection = new Section("Medium");
            var hardSection = new Section("Hard");

            var objects = array.Select(x=> x.ToObject<GameScore>()).OrderByDescending(x=> x.Score).ToList();

            foreach(var score in objects)
            {
                var element = new StringElement(score.Player,score.Score.ToString("#,###"));
                switch(score.Dificulty)
                {
                case GameDificulty.Easy:
                    easySection.Add(element);
                    break;
                case GameDificulty.Medium:
                    mediumSection.Add(element);
                    break;
                case GameDificulty.Hard:
                    hardSection.Add (element);
                    break;
                }
            }
            Root = new RootElement("High Scores")
            {
                easySection,
                mediumSection,
                hardSection,
            };
        }
开发者ID:radiofish,项目名称:monotouch-bindings,代码行数:31,代码来源:HighScoreViewController.cs


示例5: CompletedHandler

 void CompletedHandler(UIImage image, NSError error, SDImageCacheType cacheType)
 {
     if (activityIndicator != null) {
         activityIndicator.RemoveFromSuperview ();
         activityIndicator = null;
     }
 }
开发者ID:neksus,项目名称:monotouch-bindings,代码行数:7,代码来源:DetailViewController.cs


示例6: IPhoneUIApplicationDelegate

 public IPhoneUIApplicationDelegate()
     : base()
 {
     #if DEBUG
     log ("IPhoneUIApplicationDelegate constructor default");
     #endif
     IPhoneServiceLocator.CurrentDelegate = this;
     #if DEBUG
     log ("IPhoneUIApplicationDelegate creating event store instance");
     #endif
     eventStore = new EKEventStore ( );
     #if DEBUG
     log ("IPhoneUIApplicationDelegate creating address book instance");
     #endif
     if (UIDevice.CurrentDevice.CheckSystemVersion (6, 0)) {
         NSError nsError = new NSError();
         addressBook =ABAddressBook.Create(out nsError);
         #if DEBUG
         log ("IPhoneUIApplicationDelegate creating address book result: " +((nsError!=null)?nsError.Description:"no error"));
         #endif
     } else {
         addressBook = new ABAddressBook();
     }
     #if DEBUG
     log ("IPhoneUIApplicationDelegate constructor successfully ended");
     #endif
 }
开发者ID:jioe,项目名称:appverse-mobile,代码行数:27,代码来源:IPhoneUIApplicationDelegate.cs


示例7: FailedToRegisterForRemoteNotifications

 public override void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error)
 {
     if (CrossPushNotification.Current is IPushNotificationHandler)
     {
         ((IPushNotificationHandler)CrossPushNotification.Current).OnErrorReceived(error);
     }
 }
开发者ID:joaodealmeida,项目名称:EuromillionsDraws,代码行数:7,代码来源:AppDelegate.cs


示例8: GetAttributedText

        public NSAttributedString GetAttributedText()
        {
            string path = null;
            NSError error = new NSError ();

            if (TextStoragePath != null)
                path = NSBundle.MainBundle.PathForResource ("TextFiles/" + TextStoragePath[0], "");
            else
                path = NSBundle.MainBundle.PathForResource ("TextFiles/" + Title, "rtf");

            if (path == null)
                return new NSAttributedString ("");

            if (StrRichFormatting) {
                //  Load the file from disk
                var attributedString = new NSAttributedString (new NSUrl (path, false), null, ref error);

                // Make a copy we can alter
                var attributedTextHolder = new NSMutableAttributedString (attributedString);

                attributedTextHolder.AddAttributes (new UIStringAttributes () { Font = UIFont.PreferredBody },
                    new NSRange (0, attributedTextHolder.Length));
                AttributedText = (NSAttributedString)attributedTextHolder.Copy ();
            } else {
                string newFlatText = new NSAttributedString (new NSUrl (path, false), null, ref error).Value;
                AttributedText = new NSAttributedString (newFlatText, font: UIFont.PreferredBody);
            }

            return AttributedText;
        }
开发者ID:Jusliang,项目名称:Ma-Phrase-Book,代码行数:30,代码来源:TextViewModel.cs


示例9: DetailViewController

        public DetailViewController(RSSFeedItem item)
            : base(UITableViewStyle.Grouped, null, true)
        {
            var attributes = new NSAttributedStringDocumentAttributes();
              attributes.DocumentType = NSDocumentType.HTML;
              attributes.StringEncoding = NSStringEncoding.UTF8;
              var error = new NSError();
              var htmlString = new NSAttributedString(item.Description, attributes, ref error);

              Root = new RootElement(item.Title) {
                new Section{
                new StringElement(item.Author),
                new StringElement(item.PublishDate),
                        new StyledMultilineElement(htmlString),
                new HtmlElement("Full Article", item.Link)
              }
            };

            NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Action, async delegate
                {
                    var message = item.Title + " " + item.Link + " #PlanetXamarin";
                    var social = new UIActivityViewController(new NSObject[] { new NSString(message)},
                        new UIActivity[] { new UIActivity() });
                    PresentViewController(social, true, null);
                });
        }
开发者ID:KiranKumarAlugonda,项目名称:PlanetXamarin,代码行数:26,代码来源:DetailViewController.cs


示例10: TransactionEventArgs

        //        /// <summary>
        //        /// Indicates whether this transaction has any downloads.
        //        /// </summary>
        //        [Obsolete("Use the hasDownloads property.")]
        //        public readonly bool HasDownloads = false;
        /// <summary>
        /// Initializes a new instance of the <see cref="U3DXT.iOS.IAP.TransactionEventArgs"/> class.
        /// </summary>
        /// <param name="transaction">Transaction.</param>
        /// <param name="error">Error.</param>
        public TransactionEventArgs(SKPaymentTransaction transaction, NSError error = null)
        {
            this.transaction = transaction;

            try {
                hasDownloads = (transaction.downloads != null);
            } catch (Exception) {
            }

            if (error != null)
                this.error = error;
            else
                this.error = transaction.error;

            if ((transaction.transactionState == SKPaymentTransactionState.Restored)
                && (transaction.originalTransaction != null)) {
                transaction = transaction.originalTransaction;
            }

            productID = transaction.payment.productIdentifier;
            quantity = transaction.payment.quantity;

            //			this.HasDownloads = this.hasDownloads;
            //			this.Error = this.error;
            //			this.ProductID = this.productID;
            //			this.Quantity = this.quantity;
        }
开发者ID:BiDuc,项目名称:u3dxt,代码行数:37,代码来源:TransactionEventArgs.cs


示例11: DidFinishProcessingPhoto

		public void DidFinishProcessingPhoto (AVCapturePhotoOutput captureOutput, CMSampleBuffer photoSampleBuffer, CMSampleBuffer previewPhotoSampleBuffer, AVCaptureResolvedPhotoSettings resolvedSettings, AVCaptureBracketedStillImageSettings bracketSettings, NSError error)
		{
			if (photoSampleBuffer != null)
				photoData = AVCapturePhotoOutput.GetJpegPhotoDataRepresentation (photoSampleBuffer, previewPhotoSampleBuffer);
			else
				Console.WriteLine ($"Error capturing photo: {error.LocalizedDescription}");
		}
开发者ID:xamarin,项目名称:monotouch-samples,代码行数:7,代码来源:PhotoCaptureDelegate.cs


示例12: HandleImageLoaded

		private void HandleImageLoaded(UIImage image, NSError error, SDImageCacheType cacheType, NSUrl imageUrl)
		{
			if (error != null) {
				ErrorLabel.Hidden = false;
				LoadingIndicator.StopAnimating ();
			}
		}
开发者ID:Sibcat,项目名称:Slideshow,代码行数:7,代码来源:SlideController.cs


示例13: DiscoveredCharacteristic

 public override void DiscoveredCharacteristic(CBPeripheral peripheral, CBService service, NSError error)
 {
     System.Console.WriteLine ("Discovered characteristics of " + peripheral);
     foreach (var c in service.Characteristics) {
         Console.WriteLine (c.ToString ());
         peripheral.ReadValue (c);
     }
 }
开发者ID:ZachGraceffa,项目名称:Choir,代码行数:8,代码来源:ChoirCBPeripheralDelegate.cs


示例14: NetworkFailed

		public virtual void NetworkFailed(NSError error){
			Loading = false;
			InvokeOnMainThread(()=>{
				using (var popup = new UIAlertView("Error", error.LocalizedDescription, null, "OK")){
					popup.Show();
				}
			});
		}
开发者ID:escoz,项目名称:MonoMobile.Forms,代码行数:8,代码来源:FormDialogViewController.cs


示例15: PrintingComplete

		void PrintingComplete (UIPrintInteractionController printInteractionController, bool completed, NSError error)
		{
			if (completed && error != null) {
				string message = String.Format ("Due to error in domain `{0}` with code: {1}", error.Domain, error.Code);
				Console.WriteLine ("FAILED! {0}", message);
				new UIAlertView ("Failed!", message, null, "OK", null).Show ();
			}
		}
开发者ID:MobileFit,项目名称:CoachV2,代码行数:8,代码来源:Print.cs


示例16: DiscoveredService

 public override void DiscoveredService(CBPeripheral peripheral, NSError error)
 {
     System.Console.WriteLine ("Discovered a service");
     foreach (var service in peripheral.Services) {
         Console.WriteLine (service.ToString ());
         peripheral.DiscoverCharacteristics (service);
     }
 }
开发者ID:ZachGraceffa,项目名称:Choir,代码行数:8,代码来源:ChoirCBPeripheralDelegate.cs


示例17: DidFailAd

		public static void DidFailAd (this IGADCustomEventInterstitialDelegate This, GADCustomEventInterstitial customEvent, NSError error)
		{
			if (customEvent == null)
				throw new ArgumentNullException ("customEvent");
			if (error == null)
				throw new ArgumentNullException ("error");
			MonoTouch.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr_IntPtr (This.Handle, Selector.GetHandle ("customEventInterstitial:didFailAd:"), customEvent.Handle, error.Handle);
		}
开发者ID:Reedyuk,项目名称:Xamarin-Bindings,代码行数:8,代码来源:GADCustomEventInterstitialDelegate.g.cs


示例18: OnLoadError

        protected override void OnLoadError(NSError e)
        {
            base.OnLoadError(e);

            //Frame interrupted error
            if (e.Code == 102 || e.Code == -999) return;
            AlertDialogService.ShowAlert("Error", "Unable to communicate with GitHub. " + e.LocalizedDescription);
        }
开发者ID:GitWatcher,项目名称:CodeHub,代码行数:8,代码来源:LoginViewController.cs


示例19: FailedToRegisterForRemoteNotifications

 public override void FailedToRegisterForRemoteNotifications(
   UIApplication application,
   NSError error)
 {
     DonkyiOS.FailedToRegisterForRemoteNotifications(
     application,
     error);
 }
开发者ID:Donky-Network,项目名称:DonkySDK-Xamarin-Modular,代码行数:8,代码来源:AppDelegate.cs


示例20: ContentsForType

		/// <Docs>To be added.</Docs>
		/// <summary>
		/// Application developers should override this method to return the document data to be saved.
		/// </summary>
		/// <remarks>(More documentation for this node is coming)</remarks>
		/// <returns>The for type.</returns>
		/// <param name="typeName">Type name.</param>
		/// <param name="outError">Out error.</param>
		public override NSObject ContentsForType (string typeName, out NSError outError)
		{
			// Clear the error state
			outError = null;

			// Convert the contents to a NSData object and return it
			NSData docData = _dataModel.Encode(NSStringEncoding.UTF8);
			return docData;
		}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:17,代码来源:GenericTextDocument.cs



注:本文中的NSError类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# NSEvent类代码示例发布时间:2022-05-24
下一篇:
C# NSDictionary类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap