0%

本文详细介绍了 Swift 编程语言的核心特性,包括可选类型、值类型与引用类型、函数定义与调用、类与结构体等内容。通过实例讲解了 Swift 的基本语法和最佳实践,适合 iOS 开发者学习参考。

阅读全文 »

搜索

在一个字符串中搜索子字符串

  • 最灵活的方法

    • (NSRange)rangeOfString:(NSString *)aString options:(NSStringCompareOptions)mask range:(NSRange)searchRange locale:(NSLocale *)locale

格式化字符串

  • 3个方法
阅读全文 »

NSArray

##排序

  • 逆序,array.reverseObjectEnumerator.allObjects

  • 数组中是字符串对象排序首选sortedArrayUsingSelector:

    NSArray *array = @[@”John Appleseed”, @”Tim Cook”, @”Hair Force One”, @”Michael Jurewitz”];

    NSArray *sortedArray = [array sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];

阅读全文 »

#采样
米切尔最佳候选算法(Mitchell’s best-candidate algorithm)
从候选的采样点中选择出最佳采样点。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
function sample() {
var bestCandidate, bestDistance = 0;
//numCandidates为固定数量候选采样点,这个越少算法运行速度越快,越大速度慢质量高
for (var i = 0; i < numCandidates; ++i) {
var c = [Math.random() * width, Math.random() * height],
d = distance(findClosest(samples, c), c);
//最佳采样点就是距离固定点最远的那个点
if (d > bestDistance) {
bestDistance = d;
bestCandidate = c;
}
}
return bestCandidate;
}
function distance(a, b) {
var dx = a[0] - b[0],
dy = a[1] - b[1];
return Math.sqrt(dx * dx + dy * dy);
}
阅读全文 »

#基础
##单独的layer

  • 不需要附加到 view 上就能直接显示在屏幕上的单独的 layer 有 AVCaptureVideoPreviewLayer 和 CAShapeLayer
  • 改变任何属性就会触发旧值到新值

##附加到 view 上的 layer

  • 改变属性隐式动画的 layer 不起作用,UIView 默认情况是禁止 layer 动画,但是在 animation block 中能用

##CAAction

  • 当 layer 属性改变时,layer 都会寻找合适的action来实行这个改变。layer向它的delegate 发送 actionForLayer:forKey: 消息找对应的 action。如果是附加到view 上的 layer,当它的属性改变后会向 view 请求一个动作,如果这个属性的改变不是在动画 block 中是不会有效的。
1
2
3
4
5
6
7
8
9
1  //无效
2 NSLog(@"outside animation block: %@",
3 [myView actionForLayer:myView.layer forKey:@"position"]);
4 //在block才有效
5 [UIView animateWithDuration:0.3 animations:^{
6 NSLog(@"inside animation block: %@",
7 [myView actionForLayer:myView.layer forkey:@"position"]);
8 }];
9
阅读全文 »

#推送流程

1064761-91decb9285e9d812.jpg

#一些概念
1.真机证书- > 让电脑有了使用手机进行某项操作的权力(真机,推送,上线)

APP ID:程序标识符

3.真机证书制作

1.创建证书

创建CSR文件(本机的钥匙串)(CSR文件包含创建证书的电脑的一些信息,我们用电脑创建的证书,只有那一台电脑可以用)

2.1 钥匙串访问- > 证书助理-> 从证书颁发机构请求证书-> 存储到磁盘

上传CSR文件

下载cer证书文件- >双击安装到钥匙串

阅读全文 »

MarkDown.png

And now, let’s start learning to use markdown.

##INTRODUCTION
Markdown is a text-to-HTML conversion tool for web writers.Markdown allows you to write using an easy-to-read,easy-to-write plain text format,then convert it to structurally valid XHTML(or HTML).

Thus,”Markdown” is two things:(1) a plain text formatting syntax; and(2) a software tool, written inPerl, that converts the plain text formatting to HTML. See the Syntax page for detail pertaining to Markdown’s formatting syntax. You can try it out, right now, using the online Dingus.

The overriding design goal for Markdown’s formatting syntax is to make it as readable as possible. The idea is that a Markdown-formatted document should be publishable as-is, as plain text,without looking like it’s been marked up with tags or formatting instructions. While Markdown’s syntax has been influenced by several existing text-to-HTML filters, the single biggest source of inspiration for Markdown’s syntax is the format of plain text email.

The best way to get a feel for Markdown’s formatting syntax is simply to look at a Markdown-formatted document. For example, you can view the Markdown source for the article text on this page here:
http://daringfireball.net/projects/markdown/index.text

Markdown is free software,available under a BSD-style open source license.

阅读全文 »

本文详细介绍了 Markdown 语法的使用方法,包括基本语法、格式化文本、列表、链接、图片、表格等内容。通过实例讲解了如何编写清晰易读的 Markdown 文档,适合初学者阅读和参考。

阅读全文 »

这是 Hexo 博客的默认欢迎文章,介绍了 Hexo 的基本使用方法,包括创建新文章、运行服务器、生成静态文件等命令,适合 Hexo 初学者阅读。

阅读全文 »