zoukankan      html  css  js  c++  java
  • Xamarin.iOS Unified API 注意要点

    新数据类型

    NATIVE TYPE32-BIT BACKING TYPE64-BIT BACKING TYPE
    System.nint System.Int32 (int) System.Int64 (long)
    System.nuint System.UInt32 (uint) System.UInt64 (ulong)
    System.nfloat System.Single (float) System.Double (double)
    OLD TYPE IN SYSTEM.DRAWINGNEW DATA TYPEDESCRIPTION
    RectangleF CGRect Holds floating point rectangle information.
    SizeF CGSize Holds floating point size information (width, height)
    PointF CGPoint Holds a floating point, point information (X, Y)

    检查平台架构

    if (IntPtr.Size == 4) {
        Console.WriteLine ("32-bit App");
    } else if (IntPtr.Size == 8) {
        Console.WriteLine ("64-bit App");
    }

     

    Arrays and System.Collections.Generic

     集合索引需要显示转换
    public List<string> Names = new List<string>();
    ...
    
    public string GetName(nint index) {
        return Names[(int)index];
    }

    DateTime 与 NSDate需要显示转换

    下面两个扩展方法帮助实现隐式转换:

    public static DateTime NSDateToDateTime(this NSDate date)
    {
        // NSDate has a wider range than DateTime, so clip
        // the converted date to DateTime.Min|MaxValue.
        double secs = date.SecondsSinceReferenceDate;
        if (secs < -63113904000)
            return DateTime.MinValue;
        if (secs > 252423993599)
            return DateTime.MaxValue;
        return (DateTime) date;
    }
    
    public static NSDate DateTimeToNSDate(this DateTime date)
    {
        if (date.Kind == DateTimeKind.Unspecified)
            date = DateTime.SpecifyKind (date, /* DateTimeKind.Local or DateTimeKind.Utc, this depends on each app */)
        return (NSDate) date;
    }

    NSAction Replaced with Action

     

    Custom delegates replaced with Action<T>

     

    Task<bool> replaced with Task<Tuple<Boolean,NSError>>

  • 相关阅读:
    召开演示会议和总结会议
    召开每天的站立会议
    禅道管理中的项目管理--组织进行任务分解
    linux sort,uniq,cut,wc命令详解
    json2.js的用途(拯救IE)
    memcache的内存回收机制
    memcache内存分配机制
    Linux之Sed命令详解(总结一些实用例子)
    CentOS 设置网络(修改IP&修改网关&修改DNS)--update.14.08.15
    php中文字符串翻转
  • 原文地址:https://www.cnblogs.com/jimcheng/p/4486566.html
Copyright © 2011-2022 走看看