0%

参考文章

  • iOS 从入门到精通

应用程序的生命周期

iOS 应用程序拥有的 5 种状态:

  1. 【Not running】 应用还没启动或正在运行但是中途被系统停止;
  2. 【Inactive】 应用正在前台运行 (不接收事件);
  3. 【Active】 应用正在前台运行 (接收事件);
  4. 【Background 】应用处于后台运行 (还在执行代码);
  5. 【Suspended】 应用处于后台运行 (停止执行代码)。
阅读全文 »

UIDeviceOrientation

typedef NS_ENUM(NSInteger, UIDeviceOrientation) {
    UIDeviceOrientationUnknown,
    UIDeviceOrientationPortrait,            // Device oriented vertically, home button on the bottom
    UIDeviceOrientationPortraitUpsideDown,  // Device oriented vertically, home button on the top
    UIDeviceOrientationLandscapeLeft,       // Device oriented horizontally, home button on the right
    UIDeviceOrientationLandscapeRight,      // Device oriented horizontally, home button on the left
    UIDeviceOrientationFaceUp,              // Device oriented flat, face up
    UIDeviceOrientationFaceDown             // Device oriented flat, face down
}
阅读全文 »

  • GitHub 源码:RadioButton
  • star:200+
                            ⭐️⭐️⭐️ 

以下内容来源于官方源码、 README 文档、测试 Demo 或个人使用总结 !

Radio Button for iOS——iOS 单选按钮

README.md 文档描述

继承自 UIButton 的一个非常简单的类,扩展了标准的 UIButton 的功能。

可以为每个按钮配置默认和选中状态。

Demo

阅读全文 »

NSString

概述

NSString 类及其可变子类 NSMutableString 提供了一组用于处理字符串的 API,包括用于比较,搜索和修改字符串的方法。 NSString 对象在整个 Foundation 和其他 Cocoa 框架中使用,作为平台上所有文本和语言功能的基础。

Unicode 与 NSString

  • Unicode 标准为世界上几乎所有的书写系统里所使用的每一个字符或符号定义了一个唯一的数字。
  • NeXT 在 1994 年推出的 Foundation Kit 是所有编程语言中最先基于 Unicode 的标准库之一。
  • 最初,Unicode 编码是被设计为 16 位的,提供了 65,536 个字符的空间。后来,Unicode 编码扩展到了 21 位
  • NSString 代表的是用 UTF-16 编码的文本,长度、索引和范围都基于 UTF-16 的码元。
阅读全文 »

通过引用传值

调用函数时传入某个地址(也称为引用),然后由函数将数据存入该地址指向的内存。

例:

  • modf() 函数:传入一个 double 类型的数据,返回该浮点数的整数部分和小数部分。调用该函数时,需要传入一个地址供 modf () 保存整数部分的计算结果。准确的说,modf () 会返回小数部分,然后将整数部分拷贝至传入的地址。
#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[]) {

    double pi = 3.14;
    double integerPart;
    double fractionPart;

    // 将integerPart的地址作为实参传入
    fractionPart = modf(pi, &integerPart);

    // 获取integerPart地址上的值
    printf("integerPart = %.0f,factionPart = %.2f\n",integerPart,fractionPart);

    return 0;
}

输出结果

integerPart = 3,factionPart = 0.14

阅读全文 »

地址与指针

  • 1 字节(byte)= 8 位(bit)
  • 内存是有数字编号的,通常用 地址(address)来指代某个特定字节的数据。
  • 32 位 CPU 或 64 位 CPU,其实是指地址的大小。而 64 位 CPU 的寻址能力比 32 位 CPU 更强。

获取地址

  • 变量的地址:是指内存中的某个位置,该位置的内存中保存着变量的值。通过 **& 运算符 **,可以得到变量的地址。
  • %p 是针对内存地址的格式说明符。
  • 一般情况下,内存地址都会以十六进制格式输出。
int i = 17;
printf("i stores its value at %p\n",&i);

输出结果:

i stores its value at 0x7fff5fbff79c

阅读全文 »

基础数据类型

—— 摘自维基百科
image

Tips: 合理使用限定词: longlong longshortunsignedsigned 可以弹性地获取内存空间以节约内存。

阅读全文 »