
Objective-C
文章平均质量分 63
wakin002
这个作者很懒,什么都没留下…
展开
-
Work with KeyChain in IOS
What is keychain?A keychain is an encrypted container that holds passwords for multiple applications and secure services.We can use keychain to store multiple accounts in sercure FTP servers,原创 2013-01-24 11:26:21 · 643 阅读 · 0 评论 -
nil / Nil / NULL / NSNull
Understanding the concept of nothingness is as much a philosophical issue as it is a pragmatic one. We are inhabitants of a universe of somethings, yet reason in a logical universe of existential unce转载 2013-02-14 08:52:37 · 835 阅读 · 0 评论 -
applicationWillEnterForeground vs. applicationDidBecomeActive, applicationWillResignActive vs. appli
When waking up i.e. relaunching an app (either through springboard, app switching or URL)applicationWillEnterForeground: is called. It is only executed once when the app becomes ready for use, after转载 2013-01-22 14:30:11 · 2219 阅读 · 0 评论 -
IOS项目使用Git的正确步骤
0. git fetch0.1 git checkout master0.2 git pull orgin master //Get the new code from remote:master1. Create new branch by Xcode (local).2. work3. commit4. rebase(Do it before commit if necessary原创 2013-01-21 09:51:39 · 554 阅读 · 0 评论 -
Objective C 类变量的声明
Objective C中类变量的声明一般有两种方式:1)instance variable2)property方式声明instance variable方式声明如下:@interface MyClass : NSObject { NSString * _name;}如果你不想使用自动声明的set/get函数,则可以用这种方式。instance var原创 2013-02-03 17:55:31 · 1093 阅读 · 0 评论 -
如何判断一个类是否实现了某个protocol
使用-conformsToProtocol:函数,具体用法如下:@protocol MyProtocol @required- (void)onUpdate;@end@interface ProtocolTest : NSObject- (void)onUpdate;@end@interface ProtocolTestChildClass : ProtocolTest@en原创 2013-01-31 14:34:38 · 1073 阅读 · 0 评论 -
About @selector
A selector is the name used to select a method to execute for an object, or the unique identifier that replaces the name when the source code is compiled. A selector by itself doesn’t do anything. It原创 2013-01-31 14:24:47 · 536 阅读 · 0 评论 -
iCloud(三)保存Core Data数据到iCloud
iCloud综述及背景:请参照 iCloud(一)综述和iCloud(二)保存key value数据到iCloud。什么时候该用Key-Value来存储?You can set up Core Data to store its data on iCloud. If your app doesn’t have the concept of documents or files原创 2013-01-29 19:02:29 · 2072 阅读 · 1 评论 -
iOS多线程编程指南(四)线程同步
from: http://www.dreamingwish.com/dream-2012/the-ios-multithreaded-programming-guide-4-thread-synchronization.html第四章 线程同步应用程序里面多个线程的存在引发了多个执行线程安全访问资源的潜在问题。两个线程同时修改同一资源有可能以意想不到的方式互相干扰。比如,转载 2013-01-26 16:04:13 · 477 阅读 · 0 评论 -
iPhone: Detecting user inactivity/idle time since last screen touch
Has anybody implemented a feature where if the user has not touched the screen for a certain time period, you take a certain action? I'm trying to figure out the best way to do that.There's this s转载 2013-02-15 16:55:31 · 878 阅读 · 0 评论 -
Archiving Objective-C Objects with NSCoding
For the seasoned Cocoa developer, this is a piece of cake. For newer developers, this can be a real pain, especially if you don't know what you're looking for. I get this question a decent amount, so转载 2013-02-14 08:54:36 · 392 阅读 · 0 评论 -
Block 的内存管理
block 有什么意义,特点等等,这些东西,实在是太复杂了,这里只是简单的总结一下block的内存管理。而且也仅仅限于objective-C的部分Block memoryblock 的内存管理,应该是最头疼的地方,就用这个来自WWDC的例子来解释一下吧。当程序运行到这里时,stack 空间中有 shared 变量和 captured 变量。这里可以看出,__转载 2013-02-20 16:06:50 · 436 阅读 · 0 评论 -
深度解析Objective-C内存管理教程
深度解析Objective-C内存管理教程是本文要介绍的内容,不多说,来看内容。iPhone系统中的Objective-C的内存管理机制是比较灵活的,即可以拿来像C/C++一样用,也可以加个AutoreleasePool让它升级为半自动化的内存管理语言。当然,也不能拿JAVA虚拟机中的全自动化GC来比引用计数是实例对象的内存回收唯一参考引用计数(retainCount)是Objec转载 2013-05-21 09:33:15 · 677 阅读 · 0 评论 -
详解Objective-c Block应用
详解Objective-c block应用是本文要介绍的内容,主要介绍的是Objective-c block应用,不多说,先来看详细内容。Apple在C, Objective-C, C++加上Block這個延申用法。目前只有Mac 10.6 和iOS 4有支援。Block是由一堆可執行的程式組成,也可以稱做沒有名字的Function (Anonymous function)。如果是Ma转载 2013-05-21 09:31:31 · 577 阅读 · 0 评论 -
Outlet in iOS and MacOS
Outlets - Property vs. Instance VariableWhen we were writing our iPhone programming book, all of Apple's sample code and documentation used the IBOutlet keyword exactly how we had always used转载 2013-04-05 13:27:05 · 875 阅读 · 0 评论 -
iOS UIControl 几个事件的说明
在控件事件中,简单解释下下面几个事件。说明:由于是在“iOS 模拟器”中测试的,所以不能用手指,只能用鼠标。1)UIControlEventTouchDown指鼠标左键按下(注:只是“按下”)的动作2)UIControlEventTouchDownRepeat指鼠标左键连续多次重复按下(注:只是“按下”)的动作,比如,鼠标连续双击、三击、……、多次连击。说明:多次重复按下时转载 2013-04-05 13:28:35 · 611 阅读 · 0 评论 -
Class Cluster
UIButton is not a class cluster at all. A class cluster is represented by a public abstract class, that means no instance variables, with a bunch of private concrete subclasses that provide the impl转载 2013-04-04 15:36:40 · 750 阅读 · 0 评论 -
NSUserDefaults
The NSUserDefaults docs state: "NSUserDefaults caches the information to avoid having to open the user’s defaults database each time you need a default value."Therefore it's no different to sett转载 2013-03-07 17:57:17 · 667 阅读 · 0 评论 -
Anchor Point
On default, CCNode’s anchor point is (0, 0), which is at the left-bottom point.CCSprite’s anchor point is (0.5, 0.5), which is at the center.如果你把一个CCSprite作为child加入到CCNode中,CCNode的anchor point不会对s原创 2013-01-25 15:37:55 · 627 阅读 · 0 评论 -
Memory management in block
Memory management in blockBlockの具体的な使い方はhttps://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/Blocks/Articles/00_Introduction.htmlを参考してください。Blockの使うのは二つ原创 2013-02-22 16:06:05 · 412 阅读 · 0 评论 -
Manage objective c object memory in Block
Look at the document from Apple:When a block is copied, it creates strong references to object variables used within the block. If you use a blockwithin the implementation of a method:●If you ac原创 2013-02-20 17:26:06 · 590 阅读 · 0 评论 -
Open itunes by objective c
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms-apps://ax.itunes.apple.com/"]];原创 2013-01-27 00:14:44 · 336 阅读 · 0 评论 -
Core Data in IOS
iPhone中persist data有很多方法,比如NSUserDefaults,NSKeyedArchiver,SQLite3,Core Data等等,具体请参照深入理解iPhone数据持久化。今天我们主要讨论Core data。Core data是存储not-trivial数据最好的一种,它可以降低内存负荷,增加可靠性,可以让你原理底层的数据库操作。Core Data主要是对sqli原创 2013-01-27 00:13:48 · 721 阅读 · 0 评论 -
Why Schduler function is not called?
The reason it didn't work for me is that I didn't add the object to the scene layer. Apparently if it's not part of a scene, it is automatically set to paused. As for you, this should be just fine,原创 2013-01-25 15:41:23 · 481 阅读 · 0 评论 -
About contentSize, contentSizeInpixel and textureRect
texture.contentSize: texture在不同分辨率下共同的size,都是在480x320下的尺寸大小texture.contentSizeInpixel: texture的实际尺寸contentSize和textureRectsprite.contentSize: sprite的size大小sprite.textureRect: 如果是frame atla原创 2013-01-25 15:40:31 · 439 阅读 · 0 评论 -
Array Performance Comparison: C-Array vs CCArray vs NSArray vs NSMutableArray
On September 13, 2010, in cocos2d, Programming, by Steffen ItterheimWhen TechnoKinetics mentioned on Twitter he was annoyed with cocos2d, I wanted to know why. It turns out it was the change a转载 2013-01-25 15:56:29 · 554 阅读 · 0 评论 -
cocos2d 中添加显示文字的三种方式
在cocos2d 中有三个类可以在层或精灵中添加文字:CCLabelTTFCCLabelBMFontCCLabelAtlasCCLabelTTF CCLabelTTF 每次调用 setString (即改变文字)的时候,一个新的OPENGL 纹理将会被创建.。这意味着setString 和创建一个新的标签一样慢。 所以,当你转载 2013-01-25 15:44:46 · 1025 阅读 · 0 评论 -
About cocos2d color blend: (only for opengl es 1.1)
Ref: http://digitallybold.com/314/cocos2d-additive-sprite-color-tintingWe all love Cocos2d. Well, I love Cocos2d and if you’re an iOS developer I’m sure you do too. I mean why not? It’s free a转载 2013-01-25 15:43:34 · 1043 阅读 · 0 评论 -
Timers VS Scheduler
Try NOT to use Cocoa’s NSTimer. Instead use cocos2d’s own scheduler.If you use cocos2d scheduler, you will have:automatic pause/resume.when the CCLayer (CCScene, CCSprite, CCNode) ente转载 2013-01-26 15:28:03 · 333 阅读 · 0 评论 -
Porting Over iPad game to iphone the easy way cocos2d
//Add this code after "make the OpenGLView a child of the view controller" in the AppDelegate.m //This will shrink the content of the ipad to fit on the iphone smoothly. if (UI_USER_INTERFACE_ID转载 2013-01-25 15:39:12 · 419 阅读 · 0 评论 -
iCloud(二)保存key value数据到iCloud
准备:1. Add iCloud in iTunes connect. And create a new provision file and entitlements. 具体请参考refs 1.2. Only devices support iCloud. Simulator不支持iCloud.3. Add your account in your devic原创 2013-01-24 13:22:25 · 2896 阅读 · 0 评论 -
iCloud(一)综述
什么是iCloud?iCloud is a free service that lets users access their personal content on all their devices—wirelessly and automatically via Apple ID. iCloud does this by combining network-based stora原创 2013-01-24 12:01:48 · 1376 阅读 · 0 评论 -
开发适应iphone/ipad及多ios版本程序的技巧
本篇译自:Matt Gallagher的blog-http://cocoawithlove.com原文:http://cocoawithlove.com/2010/07/tips-tricks-for-conditional-ios3-ios32.html这篇日志会告诉你在ios编程中如何判断不同的版本的ios系统。1,让项目/Target支持不同版本的iOS要让一个程序可以在转载 2013-01-25 15:47:14 · 1079 阅读 · 0 评论 -
Using the Texture Atlas with cocos2d
To use pvr images, you need// Enable pre multiplied alpha for PVR textures to avoid artifacts[CCTexture2D PVRImagesHavePremultipliedAlpha:YES];How to use pvr images and plist:// Load the textu原创 2013-01-25 15:52:22 · 530 阅读 · 0 评论 -
UIView + CCNode
1. CCNode + UIView - (OK)-(void) addSomeCocoaTouch {// regular text field with rounded cornersUITextField* textField = [[UITextField alloc] initWithFrame:CGRectMake(40, 20, 200, 24原创 2013-01-26 15:42:28 · 500 阅读 · 0 评论 -
AudioServicesPlaySystemSound音频服务—IOS开发
From: http://blog.youkuaiyun.com/iukey/article/details/7296107对于简单的、无混音音频,AVAudio ToolBox框架提供了一个简单的C语言风格的音频服务。你可以使用AudioservicesPlaySystemSound函数来播放简单的声音。要遵守以下几个规则:1.音频长度小于30秒2.格式只能是PCM或者IMA4转载 2013-01-26 16:02:42 · 415 阅读 · 0 评论 -
@synchronized vs dispatch_once
From: http://bjhomer.blogspot.jp/2011/09/synchronized-vs-dispatchonce.html@synchronized vs dispatch_onceIn the comments on a recent Stack Overflow question, someone asked me if there was a signi转载 2013-01-26 15:59:55 · 550 阅读 · 0 评论 -
NSTimerは基本的にretainせずassignでよい
From: http://akisute.com/2009/05/nstimerretainassign.htmlNSTimerを初めて使ってみたのでハマったところをメモしておきます。■NSTimerはNSRunLoopにretainされる。NSTimerは引数targetで与えられたオブジェクトをretainする。いちばんハマったのがこの挙動です。AppleのNSTimerについ转载 2013-01-26 15:59:01 · 352 阅读 · 0 评论 -
iOS5 ARC学习笔记
iOS5中加入了新知识,就是ARC,其实我并不是很喜欢它,因为习惯了自己管理内存。但是学习还是很有必要的。在iOS开发过程中,属性的定义往往与retain, assign, copy有关,我想大家都很熟悉了,在此我也不介绍,网上有很多相关文章。现在我们看看iOS5中新的关键字strong, weak, unsafe_unretained. 可以与以前的关键字对应学习st转载 2013-01-26 15:57:08 · 321 阅读 · 0 评论 -
深入理解iPhone数据持久化
From: http://www.cocoachina.com/iphonedev/sdk/2010/0611/1672.html在所有的移动开发平台数据持久 化都是很重要的部分:在j2me中是rms或保存在应用程序的目录中,在symbian中可以保存在相应的磁盘目录中和数据库中。symbian中因为权限认证的原因,在3rd上大多数只能访问 应用程序的private目录或其它系统共享目录。在i转载 2013-01-26 15:49:28 · 532 阅读 · 0 评论