office API sample 

Boolean CFReadStreamSetClient(CFReadStreamRef stream, CFOptionFlags streamEvents, CFReadStreamClientCallBack clientCB, CFStreamClientContext *clientContext);

callback function define 

typedef void (*CFReadStreamClientCallBack)(CFReadStreamRef stream, CFStreamEventType type, void *clientCallBackInfo);

how to use? 

1 define use typedef style 

void AFReadStreamCallBack

(

 CFReadStreamRef aStream,

 CFStreamEventType eventType,

 void* inClientInfo

 );

void AFReadStreamCallBack

(

 CFReadStreamRef aStream,

 CFStreamEventType eventType,

 void* inClientInfo

 )

{

//do something

}

2 setup callback 

    CFStreamClientContext context = {0, (__bridge void *)(self), NULL, NULL, NULL};

    CFReadStreamSetClient(

                          stream,

                          kCFStreamEventNone|kCFStreamEventHasBytesAvailable | kCFStreamEventErrorOccurred | kCFStreamEventEndEncountered|kCFStreamEventOpenCompleted,

                          AFReadStreamCallBack,

                          &context);

    CFReadStreamScheduleWithRunLoop(stream, CFRunLoopGetCurrent(), kCFRunLoopCommonModes);


design callback sample code


#import "AppDelegate.h"

typedef void (*PF)(int x);

void func(int x)

{

    NSLog(@"func x*x=%d",x*x);

    

}

void caller(PF pf,int a,int b)

{

    int x = a+b;

    pf(x);

}

@implementation AppDelegate


-(void)caller:(PF)pf a:(int)a b:(int) b

{

    int x = a+b;

    pf(x);

}

- (void)dealloc

{

    [super dealloc];

}


- (void)applicationDidFinishLaunching:(NSNotification *)aNotification

{

    PF p1  = func;

    caller(p1,9,10);

    [self caller:p1 a:199 b:8];

    // Insert code here to initialize your application

}


caller 实现私有,指定义callback样式,不实现,具体实现是使用时候根据业务逻辑实现

C 语言的callback 和ObjC里面的protocol 是不是十分类似?



Enhanced by Zemanta

iOS Music app widget

| No Comments | No TrackBacks
iOS 5.0 增加 MPNowPlayingInfoCenter

Use a now playing info center to set now-playing information for media being played by your app.

The system displays now-playing information on the device lock screen and in the multimedia controls in the multitasking UI. If the user directs playback of your media to Apple TV via AirPlay, the now-playing information appears on the television screen. If the user connects a device to an iPod accessory, such as in a car, the accessory may display now-playing information. 

支持lock screen, AirPlay ,iPod accessory, 欢喜

看看sample code

-(void)updateInfoCenter:(UIImage*)cover

{

    MPNowPlayingInfoCenter *infoCenter=[MPNowPlayingInfoCenter defaultCenter];

    NSMutableDictionary *info=[[NSMutableDictionary alloc] initWithCapacity:2];

    [info setObject:currentSong.Artist forKey:MPMediaItemPropertyArtist];

    [info setObject:[currentSong nameStr] forKey:MPMediaItemPropertyTitle];

    MPMediaItemArtwork *itemwork=[[MPMediaItemArtwork alloc] initWithImage:cover];

    [info setObject:itemwork forKey:MPMediaItemPropertyArtwork];

    [infoCenter setNowPlayingInfo:info];

}

官方说明

Enriching Your App for AirPlay

Provide Audio Metadata

Your audio may be playing on a big-screen home theater system or on a sound system with an LCD display. Your app gives a better user experience if you provide metadata that can be shown on the AirPlay device's display, such as the artist name, song title, and album art.

Add metadata by passing a dictionary into the setNowPlayingInfo method of MPNowPlayingInfoCenter. The MPNowPlayingInfoCenter class is part of the MediaPlayerframework, but works with all playback frameworks, including MediaPlayerAVFoundation, and AudioQueue.

In addition to providing the usual song information strings, you should also pass in the playback rate, elapsed time, and media item duration. The playback device can use the duration and playback rate to create a progress bar. Update the elapsed time and playback rate whenever the playback rate changes.

看看效果,是不是比只是显示app的名字好多了。

IMG_0865.PNG

Enhanced by Zemanta

[推荐]学习Core Audio

| No Comments | No TrackBacks
Learning Core Audio.png
Audio can affect the human brain in the most powerful and profound ways. Using Apple's Core Audio, you can leverage all that power in your own Mac and iOS software, implementing features ranging from audio capture to real-time effects, MP3 playback to virtual instruments, web radio to VoIP support. The most sophisticated audio programming system ever created, Core Audio is not simple. In Learning Core Audio, top Mac programming author Chris Adamson and legendary Core Audio expert Kevin Avila fully explain this challenging framework, enabling experienced Mac or iOS programmers to make the most of it. In plain language, Adamson and Avila explain what Core Audio can do, how it works, and how it builds on the natural phenomena of sound and the human language of audio. Next, using crystal-clear code examples, they guide you through recording, playback, format conversion, Audio Units, 3D audio MIDI connectivity, and overcoming unique challenges of Core Audio programming for iOS. Coverage includes: mastering Core Audio's surprising style and conventions; recording and playback with Audio Queue; synthesizing audio; perform effects on audio streams; capturing from the mic; mixing multiple streams; managing file streams; converting formats; creating 3D positional audio; using Core MIDI on the Mac; leveraging your Cocoa and Objective-C expertise in Core Audio's C-based environment, and much more. When you've mastered the "black arts" of Core Audio, you can do some serious magic. This book will transform you from an acolyte into a true Core Audio wizard.

iOSCon2012 会议讲稿

| No Comments | No TrackBacks

new iPad 牛排

| No Comments | No TrackBacks
毫无疑问new iPad 内存是1GB,但是我们怎么获取这个数值呢?
做iOS app开发的程序员,估计很少有人知道SYSCTL(8)
我们看看SYSCTL(8)是干什么的?

[SSD-2:~] yarshure% man sysctl
sysctl -- get or set kernel state
此处省略x 行
HISTORY
     sysctl first appeared in 4.4BSD.

BSD                             March 23, 2012                             BSD

输出保函
[SSD-2:~] yarshure% sysctl -a | cut -d. -f1|sort -u
appleprofile
audit
debug
hw 这个我们比较关系,硬件参数
kern
machdep
net
security
user
vfs
vm

hw.machine = iPad3,1 这个大家都知道
hw.model = J1AP 开发代号?
hw.ncpu = 2 我是双核的
hw.byteorder = 1234 CPU字节序
hw.physmem = 1035976704 真机内存 1035976704/1024/1024=987M 近似1G
hw.usermem = 907300864 用户态内存 907300864/1024/1024 = 865M 和上面差122M,这个是kernel 占用的?还是预留给GPU用的呢?
hw.pagesize = 4096  page 大小
hw.epoch = 1
hw.vectorunit = 0
hw.busfrequency = 250000000 238ZHz
hw.cpufrequency = 1000000000 1GHz
hw.cachelinesize = 32  不熟悉这
hw.l1icachesize = 32768 Gives the size in bytes of the processor's cache lines.
hw.l1dcachesize = 32768 L1 cache size
hw.l2settings = 1
hw.l2cachesize = 1048576 L2 cache size
hw.tbfrequency = 24000000 This gives the time base frequency used by the OS and is the basis of all timing services.
hw.memsize = 1035976704 ==hw.physmem 
hw.availcpu = 2 可使用的cpu数量

完善输出可以下载下面的文件

xnu 代码关于sysctl 的一些说明


sysctl_iPhone5.txt 给研究iPhone5硬件的朋友


sysctl.ipa 附赠企业证书签名 iPa文件

NSString 和hex code 互转

| No Comments | No TrackBacks

NSString *artist=@"王杰";

NSString *song=@"什么时候才能够";


转换后

Artist=8B737067&Title=C04E484EF66519504D62FD801F59

算法

-(NSString*)toUnichar:(NSString*)src

{

    NSMutableString *arX=[NSMutableString string];

    for (int i = 0 ; i<[src length]; i++) {

        unichar ch= [src characterAtIndex:i];

        unichar b = ((((unsigned long)(ch) & 0xff00) >> 8) | (((unsigned long)(ch) & 0x00ff) << 8));

        [arX appendFormat:@"%X",b];

    }

    return arX;

}

反转

NSString *str=@"32003000310032003C68B1838E7FF397504E27595659ED70E8954C6BF266A86350830A00ED70E8950F5CF48B92634C889C69"

2012格莱美音乐大奖热门歌曲推荐


算法

-(NSString*)toString:(NSString*)uniStr

 {

    NSMutableString *outStr = [NSMutableString string];

    int len=[uniStr length]/4;

    unichar *oux=alloca(len*sizeof(unichar));

    unichar *p = oux;

   

    for (int i=0; i<[uniStr length]/4; i++) {

        

        NSString *str=[uniStr substringWithRange:NSMakeRange(i*4, 4)];

        

        unichar a =toInde([str characterAtIndex:0]);//3 3c

        unichar b =toInde([str characterAtIndex:1]);//2

        unichar c =toInde([str characterAtIndex:2]) ;//0 68

        unichar d =toInde([str characterAtIndex:3]);//0

        

        

        unichar x = c<<12+d<<8+ a<<4+b;//十进制 3c68->683c

        

        memcpy(p, &x, 2);

        printf("%c,%x",*p,x);

        p++;

        

    }

    NSString *x=[[NSString alloc] initWithCharacters:oux length:len];

    

    return outStr;

}

int toInde(unichar x)

{

    int i;

    

    switch (x) {

        case 48:

            i=0;

            break;

        case 49:

            i=1;

            break;

        case 50:

            i=2;

            break;

        case 51:

            i=3;

            break;

        case 52:

            i=4;

            break;

        case 53:

            i=5;

            break;

        case 54:

            i=6;

            break;

        case 55:

            i=7;

            break;

        case 56:

            i=8;

            break;

        case 57:

            i=9;

            break;

        case 65:

            i=10;

            break;

        case 66:

            i=11;

            break;

        case 67:

            i=12;

            break;

        case 68:

            i=13;

            break;

        case 69:

            i=14;

            break;

        case 70:

            i=15;

            break;

case 97:

            i=10;

            break;

        case 98:

            i=11

            break;

        case 99

            i=12;

            break;

        case 100:

            i=13;

            break;

        case 101:

            i=14;

            break;

        case 102:

            

            i=15;

            break;

        default:

            break;

    }

    return  i;

}



好久不写C,后面的的函数写的比较...

再奉送一个将NSString 转换成UTF8 str

-(NSString*)toUtf8Char:(NSString*)src

{

    

    NSMutableString *arX=[NSMutableString string];

    NSData *data=[src dataUsingEncoding:NSUTF8StringEncoding];

    const char *p= [data bytes];

    for (int i = 0 ; i<[data length]; i++) {

        Byte ch = *p;

        NSLog(@"%02X,%X",*p,ch);

        p++;


        [arX appendFormat:@"%X",ch];

    }

    return arX;

}

@"梁静茹丝路"转换后为

"E6A281 E99D99 E88CB9E4B89DE8B7AF"
顺便推荐一款内码查询器UnicodeChecker,官方网站 http://earthlingsoft.net
Enhanced by Zemanta

about TableView in Mac OS X

| No Comments | No TrackBacks
问题来源 Mac OS X 直到Lion 才开始支持View base TableView
 那么如果应用程序要支持10.6-,是绝对不可以使用官方的API.那么要快速实现TableView Cell自定义非常复杂。

可选方案: 1 IKImageBrowserView/IKImageBrowserCell 自定义显示比较麻烦,苹果就没想这个事情
     2 NSCollectionView/NSCollectionViewItem 同上,自定义显示不够友好

官方没有合适的,自己想偷懒,那么找一找,是不是有开源项目呢?

2 PXListView  https://github.com/Perspx/PXListView  http://perspx.com/archives/making-list-views-really-fast/ 作者关于List view 的思考
3 TwUI, Twitter on Mac https://github.com/twitter/twui  这个不介绍了,看github介绍吧
4 others may be

后续:
TwUI 使用下来不错,但是实践中遇到TUITextField 输入框和中文输入法不兼容
被迫创建多个TUINSView, 结构上感觉不是很干净,没办法,不想hack TwUI输入发兼容问题。


转一篇
原文 http://www.xuzhe.com/?p=601
首先,我说的是 iOS 开发,不是 Mac OS。

其次,这次解决的三个 BAD_ACCESS 都是由于 iOS 程序在收到 Memory Warning 后,非当前 UIViewController 执行 viewDidUnload 后出现的问题。

这类崩溃在真机上比较难测,因为是随机出现的,而且看 Crash Log 经常会看不出是哪行代码 BAD_ACCESS 了。所以这就需要善用模拟器提供的 "Hardware -> Simulate Memory Warning" 功能了。

同时为了能够方便的 Debug 出僵尸指针是谁,我在 Xcode 里加入以下三个环境变量:

NSZombieEnabled NSAutoreleaseFreedObjectCheckEnabled NSDebugEnabled

Xcode 4 的话编辑一下 Scheme,加到 Environment Variables 里即可(如果以前没加过的话)。

做完准备工作就能比较方便的进行 Debug 了。可以每切换一次 UIViewController 就模拟一次内存警告,看会不会崩溃。

接下来说说我这次遇到的三个问题。
1、一个低级错误

由于我们有时会几个人同时改一个文件,结果就发生了A用完一个实例以后顺手给释放掉了,但是却把B写在 viewDidUnload 里的代码给留下了。自然也就过度释放了。

这类过度释放的错误比较容易发现,只要改代码的时候稍微在原有文件里做一下搜索就能避免。

2、关于 Interface Builder 里的实例生命周期有多长的问题。

开发过 Mac OS 应用的同学都知道在开发 Mac 应用的时候,IB 里的实例 IBOutlet 到代码里是不用 retain 的。但是在 iOS 里却是要 retain 的。

这有什么区别呢?

如果你用的是 UIView 的话,的确,在 iOS 里不做 retain 也不要紧。因为 UIViewController 里的 UIView 本质上都是被 addSubview 到别的 UIView(UIWindow)里去的。但如果你在 IB 里放的是一个 NSObject,问题就出来了。

这也就是我遇到的问题。iOS 会把这个 NSObject 释放掉!

找这个问题花了我不少功夫,因为这个 NSObject 我只是在 IB 里连了连线,压根儿就没在代码里出现......解决方法其实很简单,在代码里加上

@property (nonatomic, retain) NSObject *someObject;

就好了(注意内存释放)。

3、BCTabBarController 带来的噩梦

在解决了以上问题后,整个程序仍然在满世界地不停的崩溃。这让我也很崩溃。咱好歹也算对 iOS 内存管理略有心得,搞个程序崩成这样实在是说不过去。

继续找下去发现问题出在一个第三方的开源控件:BCTabBarController 上。

用一个水准不高的第三方控件的结果就是给开发带来一定方便的同时,也带来了更多的麻烦(我不是在指责 BCTabBarController 的水准,因为要在苹果有限的公开 API 上完全自己来模拟原生 UITabBarController 的行为,的确是有难度的)。

这次的问题出在 BC 调用其管理的 UIViewController 的 viewWillAppear: 函数时,忽略了该 UIViewController 可能已经 viewDidUnload 过了。一上来就直接调用 viewWillAppear: ,结果当然不是崩掉就是逻辑乱掉。

解决方法是在 BC 调用 [viewController viewWillAppear:NO]; 之前加一句 [viewController view]; ,确保 viewDidLoad 先于 viewWillAppear: 被调用即可。

注:loadView 和 viewDidLoad 都不应该自己直接去调用,用 [viewController view]; 这种方法来让 view 自行载入的好处是,如果 view 已经被载入了,这一步操作不会让所有 view 再被载入一次。

现已发现的问题就是这么多,要在 iOS 上写个没有内存泄露又不会崩溃的程序实在是有难度。

无题

| No Comments | No TrackBacks
晚上和哥哥姐姐在IM上聊了很多
总想写很多事情,但是不知道如何写起。

将来的某一天会下吧。

UsingBlocksAsContextInfo - Demonstrates how to implement Objective-C "blocks" passed in as the 'contextInfo' to NSAlert, helping to handle the alert result.


// This is a quick tip on how to use the context info as a block parameter.

// You can use this type of pattern for any methods that have a delegate/selector/contextInfo pattern.

- (void)btnShowAlertClicked:(id)sender  {

    NSAlert *alert = [NSAlert alertWithMessageText:@"Alert Message"

                                     defaultButton:@"Default Button"

                                   alternateButton:@"Alternate Button"

                                       otherButton:@"Other Button"

                         informativeTextWithFormat:@"Informative Text"];

    

    BOOL someLocalVariable = YES;

    

    // We create a block that can easily access local variables to this method.

    // This is much easier than trying to package them all up into a contextInfo object

    void (^blockCallback)(NSInteger) = ^(NSInteger returnCode) {

        // Inside the block callback we can easily access locals

        if (someLocalVariable) {

            if (returnCode == NSAlertDefaultReturn) {

                [button setTitle:@"Default Return Button Clicked!"];

            } else {

                [button setTitle:@"Something else clicked...try again."];

            }

        }

    };

    

    // We copy the block, since it needs to stay alive for longer than the current scope

    [alert beginSheetModalForWindow:self.window

                      modalDelegate:[self class]

                     didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:)

                        contextInfo:Block_copy(blockCallback)];

}


+ (void)alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void (^)(NSInteger returnCode))continuationHandler {

    continuationHandler(returnCode);

    // The block must always be retained before the first call. This is the matching release

    Block_release(continuationHandler);

}


| No Comments | No TrackBacks

static void _processData(AppDelegate *self, NSInteger i) {

    // Notice that the _window can be accessed here, even though it is a private ivar

    // A compiler error (or warning) will happen if this method was outside the @implementation scope of AppDelegate.

    NSLog(@"Processing %d in window %@", i, self->_window);

}


- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {

    for (NSInteger i = 0; i < 200; i++) {

        _processData(self, i);

    }

}

@金色

| No Comments | No TrackBacks
kong_hometown.JPG
@yarshure 2011.09.19 下午  

AppKit 一点笔记(三)

| No Comments | No TrackBacks
程序如何运行?
  入口main函数
  
#import <Cocoa/Cocoa.h>
 
int main(int argc, char *argv[])
{
    return NSApplicationMain(argc,  (const char **) argv);
}
  
应用程序主进程开启
 通过Info.plist 查找 NSMainNibFile,并load之
NSMainNibFile 文件Load完成后,下一步NibFile中"File's owner' 回调用awakeFromNib
10.6 之后支持[super awakeFromNib]

程序启动完成

程序状态管理和维护通过

NSApplication,NSApplicationDelegate 

NSNibLoading,单独load

使用NSBundle 3个方法

  

+ (BOOL)loadNibFile:(NSString *)fileName externalNameTable:(NSDictionary *)context withZone:(NSZone *)zone;

+ (BOOL)loadNibNamed:(NSString *)nibName owner:(id)owner;

- (BOOL)loadNibFile:(NSString *)fileName externalNameTable:(NSDictionary *)context withZone:(NSZone *)zone;


看起来第二个更简单些

  


另外Document base Application NSDocument 类可以使用

- (NSString *)windowNibName;方法加载目标Nib文件


NSWindowController 同样可以使用上面的这个方法


AppKit 一点笔记(二)

| No Comments | No TrackBacks
1 Dock Menu 效果如图
dock_menu.png
实现方法

NSApplicationDelegate

实现

- (NSMenu *)applicationDockMenu:(NSApplication *)sender

{

    return _menu;

}

2 状态条菜单

  需要NSMenuDelegate protocol

@protocol NSMenuDelegate <NSObject>

@optional

- (void)menuNeedsUpdate:(NSMenu*)menu;


- (NSInteger)numberOfItemsInMenu:(NSMenu*)menu;

- (BOOL)menu:(NSMenu*)menu updateItem:(NSMenuItem*)item atIndex:(NSInteger)index shouldCancel:(BOOL)shouldCancel;

- (void)menuWillOpen:(NSMenu *)menu;

- (void)menuDidClose:(NSMenu *)menu;

- (void)menu:(NSMenu *)menu willHighlightItem:(NSMenuItem *)item;

@end


statbar_menu.png

StatusBar加Icon

- (void)activateStatusMenu:(int)status

{

    NSStatusBar *bar = [NSStatusBar systemStatusBar];

    icon = [bar statusItemWithLength:NSVariableStatusItemLength];

    [icon retain];

NSString* filePath;

switch (status) {

case 0:

filePath = [[NSBundle mainBundle] pathForResource:@"sync_complete" ofType:@"png"];

break;

case 1:

filePath = [[NSBundle mainBundle] pathForResource:@"sync_processing" ofType:@"png"];

break;

case 2:

filePath = [[NSBundle mainBundle] pathForResource:@"sync_error" ofType:@"png"];

break;

default:

break;

}

NSImage* image = [[NSImage alloc] initWithContentsOfFile:filePath];

[icon setImage:image];

[icon setHighlightMode:YES];

[icon setMenu:mainMenu];

}


关于菜单就讲这么多

AppKit 一点笔记

| No Comments | No TrackBacks

NSWindowController

- (id)initWithWindow:(NSWindow *)window

或者使用 - (NSString *)windowNibName

NSWindowController *controller = [[c alloc] init];

    if (_windowControllers == nil) {

        _windowControllers = [NSMutableArray new];

    }

    [_windowControllers addObject:controller];

    [controller showWindow:self];//显示Window,self 为NSWindowController

    [controller release];


注册窗口关闭通知

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowClosed:) name:NSWindowWillCloseNotification object:nil];


处理关闭窗口通知,移出不需要的Window

- (void)_windowClosed:(NSNotification *)note {

    NSWindow *window = [note object];

    for (NSWindowController *winController in _windowControllers) {

        if (winController.window == window) {

            [[winController retain] autorelease]; // Keeps the instance alive a little longer so things can unbind from it

            [_windowControllers removeObject:winController];

            break;

        }

    }

}

Enhanced by Zemanta

sysctl on iOS5

| No Comments | No TrackBacks
iPhone4.txt



See iPhone4s hardware  info 

hw.machine = iPhone4,1
hw.model = N94AP
hw.ncpu = 2
hw.byteorder = 1234
hw.physmem = 529481728
hw.usermem = 447721472
hw.pagesize = 4096
hw.epoch = 1
hw.vectorunit = 0
hw.busfrequency = 200000000
hw.cpufrequency = 800000000
hw.cachelinesize = 32
hw.l1icachesize = 32768
hw.l1dcachesize = 32768
hw.l2settings = 1
hw.l2cachesize = 1048576
hw.tbfrequency = 24000000
hw.memsize = 529481728
hw.availcpu = 2

开发中使用了 http://opensource.apple.com/ 开发的项目 system_cmds 中sysctl 


Enhanced by Zemanta

Steven P. Jobs 1955-2011

| No Comments | No TrackBacks


IMG_0002.jpg
苹果失去了一位富有远见和创造力的天才,世界失去了一位神人。我们这些有幸认识史蒂夫并与之公事的人们,失去了一位亲爱的朋友和激励我们的精神导师。史蒂夫留下了一个只有他才能开创的公司,他的精神将永远是苹果的基石。(苹果官网,孙方翻译)

#pragma mark KVO

- (void)observeValueForKeyPath:(NSString *)keyPath

                      ofObject:(id)object

                        change:(NSDictionary *)change

                       context:(void *)context

{

NSLog(@"dict= %@ obj= %@,keypath=%@",change,object,keyPath);

//    if (object ==xxx) {

//        if ([keyPath isEqualToString:@"title"]) {

//            

//        }else if ([keyPath isEqualToString:@"name"]) {

//            

//        }

//    } else if(object == bbb){

//        

//    }

    if (context == 123) {

        

    } else if(context == 456){

        

    }

    

}

-(void)traceObj:(Entry*)obj

{

[obj addObserver:self

  forKeyPath:@"title"

options:0

context:123];

    [obj addObserver:self

  forKeyPath:@"name"

options:0

context:456];

    [objB addObserver:self

  forKeyPath:@"name"

options:0

context:NULL];

}

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.

-(void)viewDidLoad

{

[super viewDidLoad];


Entry *entry =[[Entry alloc] init];

[self traceObj:entry];

[entry setValue:@"abc" forKey:@"title"];

id msg=[entry valueForKey:@"titl"];

NSLog(@"%@",msg);

[[NSNotificationCenter defaultCenter] addObserver:self 

selector:@selector(keyboardShow:)

name:UIKeyboardWillShowNotification 

  object:nil];

[[NSNotificationCenter defaultCenter] addObserver:self 

selector:@selector(keyboardShow:)

name:UIKeyboardWillHideNotification

  object:nil];

[[NSNotificationCenter defaultCenter] addObserver:self 

selector:@selector(textChanged:)

name:UITextFieldTextDidChangeNotification

  object:nil];

}

-(void)textChanged:(NSNotification*)noti

{

NSLog(@"%@ %@",input.text,[noti userInfo]);

NSString *sTr =input.text;

if ([sTr length] >=10) {

input.text = [sTr substringWithRange:NSMakeRange(0,9)];

UIAlertView *alert=[[[UIAlertView alloc] initWithTitle:@"title" message:@"message" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"2",@"cancel",nil] autorelease];

[alert show];

}

NSMutableArray *array=[[NSMutableArray alloc] initWithCapacity:10];

}

-(void)keyboardShow:(NSNotification*)noti

{

if ([[noti name] isEqualToString:UIKeyboardWillShowNotification]) {

input.center = CGPointMake(input.center.x, input.center.y-200);

} else {

input.center = CGPointMake(input.center.x, input.center.y+200);

}


}

######################################

@implementation Entry

@synthesize title;

@synthesize price;

@synthesize image53;

@synthesize image;



-(id)valueForUndefinedKey:(NSString *)key

{

return [NSString stringWithFormat:@"%@ not have value for key %@",self,key];

}

-(void)setValue:(id)value forUndefinedKey:(NSString *)key

{

}


Enhanced by Zemanta

东北老家小河

| No Comments | No TrackBacks
儿时夏季经常在河里游泳
拍摄于2011年9.19 傍晚

IMG_0189.jpg

昨天写的script

| No Comments | No TrackBacks

#!/bin/sh

apppath=`xcodebuild |grep Validation|awk '{print $2}'`

sign='iPhone Distribution:Yarshure Kong Healthcare Communications Co., Ltd.'

ipapath=`pwd`'/BlanceBall.ipa'

echo $apppath

/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/PackageApplication  -s "$sign" "$apppath" -o "$ipapath"

scp "$ipapath" macgeeks:~/macgeeks.cn/bbs/apps/


Enhanced by Zemanta

Find recent content on the main index or look in the archives to find all content.

Recent Comments

  • 1o1efdgdg: 初来乍到,请多多关照。 read more
  • Cisbye Xue: 树欲静而风不止,子欲养而亲不待。 节哀! read more
  • kevin: 楼主,可否给个联系方式,有问题请教你... 我按照你blog给出的命令 : libtool -dynamic -arch_only armv6 -syslibroot [file] -L read more
  • 孔祥波: 1,2,3已经称为过去时 4,5有待继续 6 零花钱是有了 7 iPad2,iPhone4,kindle3都有了 下半年要的计划呢? read more
  • iamdaiyuan: 节哀。好好珍惜身边的人吧 read more
  • xian.suzhou: 另外,我是苏州大学的一名老师,我们现在也在进行iphone输入法的开发。看到前面陈心涛同学给你的留言,想和他讨论一些输入法的问题,是否能提供他的邮箱地址?谢谢了! read more
  • xian.suzhou: 不知楼主会不会看到这个留言了,呵呵,我也想要一个例子,能发发给我一份,谢谢了! read more
  • iphonemaker: 具体怎么使用,能说说嘛,最好给个demo事例,谢谢。 qq:37079765 read more
  • dbanotes: 电子设备都有啥?要不帮我做点零活儿,我帮你解决掉好了 read more
  • meggy.meng: 恩 是需要做点计划 read more

Recent Assets

  • tweet201212.png
  • tweet.png
  • 屏幕快照 2012-12-06 下午4.37.58.png
  • 2012-12-06.4.38.19.png
  • IMG_0865.PNG
  • Learning Core Audio.png
  • channel.png
  • airplay_func_ver.png
  • preview.png
  • AirPlay.png

页面

OpenID accepted here Learn more about OpenID
Powered by Movable Type 4.37