本文整理汇总了C#中NSError类的典型用法代码示例。如果您正苦于以下问题:C# NSError类的具体用法?C# NSError怎么用?C# NSError使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NSError类属于命名空间,在下文中一共展示了NSError类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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;
}
示例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 ();
});
}
}
示例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,
};
}
示例5: CompletedHandler
void CompletedHandler(UIImage image, NSError error, SDImageCacheType cacheType)
{
if (activityIndicator != null) {
activityIndicator.RemoveFromSuperview ();
activityIndicator = null;
}
}
示例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
}
示例7: FailedToRegisterForRemoteNotifications
public override void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error)
{
if (CrossPushNotification.Current is IPushNotificationHandler)
{
((IPushNotificationHandler)CrossPushNotification.Current).OnErrorReceived(error);
}
}
示例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;
}
示例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);
});
}
示例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;
}
示例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}");
}
示例12: HandleImageLoaded
private void HandleImageLoaded(UIImage image, NSError error, SDImageCacheType cacheType, NSUrl imageUrl)
{
if (error != null) {
ErrorLabel.Hidden = false;
LoadingIndicator.StopAnimating ();
}
}
示例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);
}
}
示例14: NetworkFailed
public virtual void NetworkFailed(NSError error){
Loading = false;
InvokeOnMainThread(()=>{
using (var popup = new UIAlertView("Error", error.LocalizedDescription, null, "OK")){
popup.Show();
}
});
}
示例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 ();
}
}