文章归档

iOS8/Swift Array数组扩展简单洗牌函数实现

Playground代码

// Playground - noun: a place where people can play
// 戴维营教育  Swift Array数组 简单洗牌函数实现
// demonstrated by 大茶园丁.


import Cocoa


/[......]

Read more

标签: , ,
文章分类 iOS 8开发

Swift编程高级教程(八)闭包

闭包

闭包是一个独立的函数功能代码段,我们可以在代码之间当作变量那样使用和传递他。Swift里的闭包和Apple的C语言和Objective-C语言里的block以及其他语言里的lambda表达式非常类似。

闭包可以capture在上下文中的任何常量和变量并在其定义内存储其引用,这就是所谓的闭合[......]

Read more

标签: , , , , , , , , , , , , , , ,
文章分类 iOS 8开发

Swift编程高级教程(三)集合类型-字典

集合类型—字典

Swift语言提供了两种集合数据类型:数组和字典,数组是一系列相同类型的变量值有序存储;字典是一系列相同类型的变量值的无序存储,可以通过一个唯一标识符(键)来引用和查找。

数组和字典总是能识别自己所能够存储的键值的类型,就是说,我们不能够往这两个容器内插入错误的类型。显式类型声明[......]

Read more

标签: , , , , , , , ,
文章分类 iOS 8开发

Swift编程高级教程(三)集合类型-数组

集合类型—数组

Swift语言提供了两种集合数据类型:数组和字典,数组是一系列相同类型的变量值有序存储;字典是一系列相同类型的变量值的无序存储,可以通过一个唯一标识符(键)来引用和查找。

数组和字典总是能识别自己所能够存储的键值的类型,就是说,我们不能够往这两个容器内插入错误的类型。显式类型声明[......]

Read more

标签: , , , ,
文章分类 iOS 8开发

Objective-C和Swift混合编程开发(一)

Objective-C和Swift混合编程开发

创建混编的Framework工程

第一步:创建target为Framework的工程

打开Xcode6-Beta,菜单栏File—>New—>Project; 创建一个新的工程,工程模板选择iOS—>FrameWork &amp[......]

Read more

文章分类 iOS 8开发

Linux 3.10中近似完全无滴嗒特性解读

一个典型的Linux操作系统中,运行中的CPU通常每秒会被时钟打断100到1000次。时钟中断是为了重新考虑应该运行哪个进程、响应读写更新(RCU)调用,以及处理其它必要的事务。这种周期性的时钟中断或滴嗒比臭名昭著的全局内核锁(BKL)要合理得多,但它的缺点是影响性能,也称不上节能。

几年前,[......]

Read more

文章分类 Linux服务器开发

公司内网Debian Server上的openvpn服务器搭建并通过SSH隧道转发到广域网

由于戴维营公司在长沙的学员,研发人员和北京的研发人员需要协同研发,故需要让北京的兄弟们加入到长沙办公室的内网,访问版本 管理服务器,于是采用在内网服务器上搭建一个OpenVPN服务,并把内网(铁道的宽带,木有分配动态的广域网ip给WAN,悲剧。)的OpenVPN服务端口通过ssh隧道转发到广域网上某[......]

Read more

文章分类 Linux服务器开发

树莓派上Qt5交叉编译移植新手指南

Raspberry Pi (BCM2835): Device Information

Architecture
ARMv6

CPU
ARM11

RAM
256MB OR 512MB since October 2012 (shared with GPU)[......]

Read more

标签: , , , ,
文章分类 Linux嵌入式开发

Objective-C不和C++那样有函数重载

今天有学员问在看Programming iOS 6的书上看到OC里不能像C++那样形式做函数重载的问题.

No Overloading

The data type returned by a method, together with the data types of each of its param‐ eters in order, constitute that method’s signature. It is illegal for two methods of the same type (class method or instance method) to exist in the same class with the same name but different signatures.

So, for example, you could not have two MyClass instance methods called myMethod, one of which returns void and one of which returns an NSString. Similarly, you could not have two MyClass instance methods called myMethod:, both returning void, one taking a CGFloat parameter and one taking an NSString parameter. An attempt to vi‐ olate this rule will be stopped dead in its tracks by the compiler, which will announce a “duplicate declaration” error. The reason for this rule is that if two such conflicting methods were allowed to exist, there would be no way to determine from a method call to one of them which method was being called.

You might think that the issue could be decided by looking at the types involved in the call. If one myMethod: takes a CGFloat parameter and the other myMethod: takes an NSString parameter, you might think that when myMethod: is called, Objective-C could look at the actual argument and realize that the former method is meant if the argument is a CGFloat and the latter if the argument is an NSString. But Objective-C doesn’t work that way. There are languages that permit this feature, called overloading, but Objective- C is not one of them. [......]

Read more

文章分类 iPhone应用开发

Linux系统调用reboot中魔术参数背后鲜为人知的趣味

Linux系统调用reboot()中魔数参数背后鲜为人知的趣味事情:

看过Linux系统调用的童鞋可能会注意到reboot系统调用的第二个参数magic2的取值到底是何意义.

在任意终端敲入 man 2  reboot 回车就可以看到reboot系统调用的原型如下:

NAME

[......]

Read more

标签: , ,
文章分类 Linux服务器开发