







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;
}
}
}
#!/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/
-(NSString*)removeHTMLTag:(NSString*)src
{
NSError *error = NULL;
NSMutableString *dest=[NSMutableString stringWithCapacity:0];
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"<a href=\".+?\">(.+?)</a>"
options:NSRegularExpressionCaseInsensitive
error:&error];
NSRegularExpression* regex2 = [[NSRegularExpression alloc] initWithPattern:@"(?<=>).*?(?=</a>)" options:NSRegularExpressionCaseInsensitive error:nil];
NSUInteger numberOfMatches = [regex numberOfMatchesInString:src
options:0
range:NSMakeRange(0, [src length])];
if (numberOfMatches !=0) {
[dest appendString:src];
[regex enumerateMatchesInString:src options:0 range:NSMakeRange(0, [src length])
usingBlock:^(NSTextCheckingResult *result, NSMatchingFlags flags, BOOL *stop) {
NSString*resultString = [src substringWithRange:[result range]];
NSString*link=[resultString substringWithRange:[[regex2 firstMatchInString:resultString options:0 range:NSMakeRange(0,[resultString length])] range]];
[dest replaceCharactersInRange:[result range] withString:link];
}];
return [dest stringByReplacingOccurrencesOfString:@"<br />" withString:@""];
} else {
return [src stringByReplacingOccurrencesOfString:@"<br />" withString:@""];
}
}
本文简要介绍如何使用KVO 跟踪NSOperation 状态
traceOperation 方法跟踪 PageLoadOperation(NSOperation 子类)
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after app launch
for (NSString *urlString in urlArray)
{
NSURL *url = [NSURL URLWithString:urlString];
PageLoadOperation *plo = [[PageLoadOperation alloc] initWithURL:url];
[queue addOperation:plo];
[self traceOperation:plo];
[plo release];
}
[window addSubview:viewController.view];
[window makeKeyAndVisible];
return YES;
}
traceOperation 方法
The NSOperation class is key-value coding (KVC) and key-value observing (KVO) compliant for several of its properties. As needed, you can observe these properties to control other parts of your application. The properties you can observe include the following:
isCancelled - read-only property
isConcurrent - read-only property
isExecuting - read-only property
isFinished - read-only property
isReady - read-only property
dependencies - read-only property
queuePriority - readable and writable property
completionBlock - readable and writable property (Mac OS X only)
-(void)traceOperation:(NSOperation*)obj
{
[obj addObserver:self
forKeyPath:@"isExecuting"
options:0
context:NULL];
[obj addObserver:self
forKeyPath:@"isFinished"
options:0
context:NULL];
[obj addObserver:self
forKeyPath:@"isReady"
options:0
context:NULL];
[obj addObserver:self
forKeyPath:@"isCancelled"
options:0
context:NULL];
}
CGRect backRect = CGRectMake(10, 10, 50, 8);
CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 1.0);
CGContextFillRect(context, backRect);
CGContextTranslateCTM(context, 0.0, self.frame.size.height);
CGContextScaleCTM(context, 1.0, -1.0);
CGContextShowTextAtPoint 不能draw中文,中文等UTF8 需要用