Sunday, March 30, 2014
Sunday, March 23, 2014
NSTextview auto resize when window resize frame
[oneTV setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
Saturday, March 22, 2014
NSArray Call one Function for all item at once
[_buttonArray makeObjectsPerformSelector:@selector(setState:) withObject:(id)NSOffState]; [sender setState:NSOnState];
Tuesday, March 18, 2014
PDF Form Editor
A must-have app that will save you time and eliminate the need to print, fax or mail documents and forms for signature. Once you've tried it, you'll wonder how you ever got along without it!
As it turns out, We end up having to sign a lot of documents, such as contracts, IRS forms, and the like. Many of these are in PDF form (bravo), and some even let us fill them out via my keyboard (even better).
Luckily, PDF Form Editor makes all that superflous. It’s super easy to get your pen and paper signature onto a PDF. Here’s how.
• Add Text,you can create text content on any PDF page, including images
• Sign documents with Mac
• Documents are imported and sent directly from your computer to maintain complete privacy and security.
• No need to print, sign, or fax documents again
• Full Offline - Sign documents offline, never fear bad internet in front of clients
• Draw a shape on your PDF File,you can draw, position and resize a multitude of shapes, including Rectangles, Lines, Circle.
• Export into a PDF
Download Link
https://itunes.apple.com/us/app/pdf-form-editor/id845467240?mt=12
As it turns out, We end up having to sign a lot of documents, such as contracts, IRS forms, and the like. Many of these are in PDF form (bravo), and some even let us fill them out via my keyboard (even better).
Luckily, PDF Form Editor makes all that superflous. It’s super easy to get your pen and paper signature onto a PDF. Here’s how.
• Add Text,you can create text content on any PDF page, including images
• Sign documents with Mac
• Documents are imported and sent directly from your computer to maintain complete privacy and security.
• No need to print, sign, or fax documents again
• Full Offline - Sign documents offline, never fear bad internet in front of clients
• Draw a shape on your PDF File,you can draw, position and resize a multitude of shapes, including Rectangles, Lines, Circle.
• Export into a PDF
Download Link
https://itunes.apple.com/us/app/pdf-form-editor/id845467240?mt=12
Monday, March 10, 2014
NSWindow Show as Sheet
我想做一个Word Collection类的app,因此需要实现显示“加入item”的功能。开始使用NSPopover,但是NSTextview却无法响应输入。google半天,后来发现可能是apple不推荐在NSPopover上使用NSTextview。因此,切换成使用NSPanel了
具体使用方法
(1)
@interface SheetDemoWC : NSWindowController
{
IBOutlet NSPanel *theSheet;
}
- (IBAction) showTheSheet:(id)sender ;
@end
- (IBAction) showTheSheet:(id)sender {
[NSApp beginSheet:theSheet
modalForWindow:self.window
modalDelegate:self
didEndSelector:nil
contextInfo:nil];
}
-(IBAction)endTheSheet:(id)sender {
[NSApp endSheet:theSheet];
[theSheet orderOut:sender];
}
(2)添加panel,然后就可以按照自己需要添加控件了。由于NSPanel继承自NSWindow,所以可以使用NSTextview
具体使用方法
(1)
@interface SheetDemoWC : NSWindowController
{
IBOutlet NSPanel *theSheet;
}
- (IBAction) showTheSheet:(id)sender ;
@end
- (IBAction) showTheSheet:(id)sender {
[NSApp beginSheet:theSheet
modalForWindow:self.window
modalDelegate:self
didEndSelector:nil
contextInfo:nil];
}
-(IBAction)endTheSheet:(id)sender {
[NSApp endSheet:theSheet];
[theSheet orderOut:sender];
}
(2)添加panel,然后就可以按照自己需要添加控件了。由于NSPanel继承自NSWindow,所以可以使用NSTextview
Wednesday, February 26, 2014
Comic Reader PDF Mac OS App
Your iMac or MacBook is the perfect device for reading comics, but reading comics and manga isn't like reading books. You need a specialist app that can:
1、Fullscreen: Maximize viewing area;
2、Page Layout: Pages laid out as they would be in print;
3、Page Ordering: Left to right or right to left;
4、Page Scaling: Original size, window fit and horizontal;
5、Archive Handling: Seamlessly deals with .cbr, .cbz, .zip, .rar, tar, 7z, lha and others;
6、Multiple Sessions: View multiple comics at one time;
7、Auto-save: Comics are automatically bookmarked and reopened at launch;
8、Page Rotation: Rotate the pages to maximize display area;
9、Image Loupe: Zoom in on small details;
10、Full Screen Thumbnail View: Quickly find the page you want;
Download Link
https://itunes.apple.com/us/app/comic-reader-pdf/id829508509?mt=12
1、Fullscreen: Maximize viewing area;
2、Page Layout: Pages laid out as they would be in print;
3、Page Ordering: Left to right or right to left;
4、Page Scaling: Original size, window fit and horizontal;
5、Archive Handling: Seamlessly deals with .cbr, .cbz, .zip, .rar, tar, 7z, lha and others;
6、Multiple Sessions: View multiple comics at one time;
7、Auto-save: Comics are automatically bookmarked and reopened at launch;
8、Page Rotation: Rotate the pages to maximize display area;
9、Image Loupe: Zoom in on small details;
10、Full Screen Thumbnail View: Quickly find the page you want;
Download Link
https://itunes.apple.com/us/app/comic-reader-pdf/id829508509?mt=12
Tuesday, February 25, 2014
mac hg
安装Mercurial
在命令行中输入:
然后输入管理员密码,自动下载并安装
然后就可以用hg更新源代码了
例如:
在命令行中输入:
sudo easy_install mercurial
然后就可以用hg更新源代码了
例如:
hg clone https://code.google.com/p/core-plot/
Monday, February 24, 2014
Key directories for Mac apps
Directory | Description |
---|---|
Applications directory | This is the installation directory for your app bundle. The path for the global Applications directory is /Applications
but each user directory may have a local applications directory
containing user-specific apps. Regardless, you should not need to use
this path directly. To access resources inside your application bundle,
use an NSBundle object instead.For more information about the structure of your application bundle and how you locate resources, see “The OS X Application Bundle.” |
Home directory | The configuration of your app determines the location of the home directory seen by your app:
NSHomeDirectory function. |
Library directory | The
Library directory is the top-level directory for storing private
app-related data and preferences. There are several Library directories
scattered throughout the system but you should always use the one
located inside the current home directory. Do not store files directly at the top-level of the Library directory. Instead, store them in one of the specific subdirectories described in this table. In OS X v10.7 and later, the Finder hides the Library directory in the user’s home folder by default. Therefore, you should never store files in this directory that you want the user to access. To get the path to this directory use the NSLibraryDirectory search path key with the NSUserDomainMask domain. |
Application Support directory | The
Application Support directory is where your app stores any type of file
that supports the app but is not required for the app to run, such as
document templates or configuration files. The files should be
app-specific but should never store user data. This directory is located
inside the Library directory. Never store files at the top level of this directory: Always put them in a subdirectory named for your app or company. If the resources apply to all users on the system, such as document templates, place them in /Library/Application Support . To get the path to this directory use the NSApplicationSupportDirectory search path key with the NSLocalDomainMask domain. If the resources are user-specific, such as workspace configuration files, place them in the current user’s ~/Library/Application Support directory. To get the path to this directory use the NSApplicationSupportDirectory search path key with the NSUserDomainMask domain. |
Caches directory | The
Caches directory is where you store cache files and other temporary
data that your app can re-create as needed. This directory is located
inside the Library directory. Never store files at the top level of this directory: Always put them in a subdirectory named for your app or company. Your app is responsible for cleaning out cache data files when they are no longer needed. The system does not delete files from this directory. To get the path to this directory use the NSCachesDirectory search path key with the NSUserDomainMask domain. |
Movies directory | The Movies directory contains the user’s video files. To get the path to this directory use the NSMoviesDirectory search path key with the NSUserDomainMask domain. |
Music directory | The Music directory contains the user’s music and audio files. To get the path to this directory use the NSMusicDirectory search path key with the NSUserDomainMask domain. |
Pictures directory | The Pictures directory contains the user’s images and photos. To get the path to this directory use the NSPicturesDirectory search path key with the NSUserDomainMask domain. |
Temporary directory | The
Temporary directory is where you store files that do not need to
persist between launches of your app. You normally use this directory
for scratch files or other types of short-lived data files that are not
related to your app’s persistent data. This directory is typically
hidden from the user. Your app should remove files from this directory as soon as it is done with them. The system may also purge lingering files from this directory at system startup. To get the path to this directory use the NSTemporaryDirectory function. |
Predicate Programming Guide
The pragmas are publicly documented at http://sqlite.org/pragma.html.
You can set both pragmas using the key
NSSQLitePragmasOption
in the options dictionary when opening the store. The NSSQLitePragmasOption
dictionary contains pragma names as keys and string values as objects, as illustrated in the following example:https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Predicates/predicates.html#//apple_ref/doc/uid/TP40001789
https://developer.apple.com/library/mac/documentation/General/Conceptual/MOSXAppProgrammingGuide/AppRuntime/AppRuntime.html
stduy Document Base App
1. icloud
Storing Documents in iCloud
For example, you might store the text and illustrations for a book in document storage, and you might store the reader’s page location in key-value storage. That way, whenever the user opens the document on any device, the correct page is displayed.
“Moving Document Data to and from iCloud.”
Thursday, February 20, 2014
NSAlert how to use
//---------------------------
- (void)convertDidFinished:(NSString *) outputPath
{
// NSWindowWillCloseNotification
static BOOL runAgain = YES;
// [saveasPDFBT setEnabled:YES];
//NSAlert
if (runAgain == NO) // Suppression button: if user doesn't want to see alert, return
return;
NSAlert *alert = [[[NSAlert alloc] init] autorelease];
[alert addButtonWithTitle:@"Open File"];
[alert addButtonWithTitle:@"Close"];
[alert setMessageText:@"Convert Finished"];
[alert setInformativeText:@"Images had been converted to icns"];
[alert setAlertStyle:NSWarningAlertStyle];
[alert setShowsSuppressionButton:YES]; // Suppression button: show it
// [alert setAccessoryView:myView]; // Accessory view: "my" accessed via an outlet connection
NSInteger result = [alert runModal];
if ( result == NSAlertFirstButtonReturn ) {
NSString * onePath=outputPath;
[[NSWorkspace sharedWorkspace] openFile:onePath];
// "Delete" clicked
// [self deleteRecord:currentRec];
} else if ( result == NSAlertSecondButtonReturn ) { // Accessory view: handle user-specified data
// "Extend" clicked
}
runAgain = (BOOL)![[alert suppressionButton] state]; // Suppression button: get state of button
//[alert release];
}
- (void)convertDidFinished:(NSString *) outputPath
{
// NSWindowWillCloseNotification
static BOOL runAgain = YES;
// [saveasPDFBT setEnabled:YES];
//NSAlert
if (runAgain == NO) // Suppression button: if user doesn't want to see alert, return
return;
NSAlert *alert = [[[NSAlert alloc] init] autorelease];
[alert addButtonWithTitle:@"Open File"];
[alert addButtonWithTitle:@"Close"];
[alert setMessageText:@"Convert Finished"];
[alert setInformativeText:@"Images had been converted to icns"];
[alert setAlertStyle:NSWarningAlertStyle];
[alert setShowsSuppressionButton:YES]; // Suppression button: show it
// [alert setAccessoryView:myView]; // Accessory view: "my" accessed via an outlet connection
NSInteger result = [alert runModal];
if ( result == NSAlertFirstButtonReturn ) {
NSString * onePath=outputPath;
[[NSWorkspace sharedWorkspace] openFile:onePath];
// "Delete" clicked
// [self deleteRecord:currentRec];
} else if ( result == NSAlertSecondButtonReturn ) { // Accessory view: handle user-specified data
// "Extend" clicked
}
runAgain = (BOOL)![[alert suppressionButton] state]; // Suppression button: get state of button
//[alert release];
}
Retina Image Resize NSImage
-(NSSize) getNormalImageSize:(NSSize) oneSize
{
CGFloat screenScale = [[NSScreen mainScreen] backingScaleFactor];
float targetScaledWidth =oneSize.width/screenScale;
float targetScaledHeight = oneSize.height/screenScale;
return NSMakeSize(targetScaledWidth, targetScaledHeight);
}
- (NSImage*)resize:(NSSize)destSize
{
NSSize oldSize=destSize;
destSize=[self getNormalImageSize:destSize];
NSAssert([[self representations] count], @"Bad Input Image...");
NSImage *newImage = [[[NSImage alloc]initWithSize:destSize] autorelease];
[newImage lockFocus];
[self drawInRect:NSMakeRect(0, 0, destSize.width, destSize.height)
fromRect:NSMakeRect(0, 0, self.size.width, self.size.height)
operation:NSCompositeSourceOver fraction:1.0];
[newImage unlockFocus];
[newImage setSize:oldSize];
return newImage;
}
{
CGFloat screenScale = [[NSScreen mainScreen] backingScaleFactor];
float targetScaledWidth =oneSize.width/screenScale;
float targetScaledHeight = oneSize.height/screenScale;
return NSMakeSize(targetScaledWidth, targetScaledHeight);
}
- (NSImage*)resize:(NSSize)destSize
{
NSSize oldSize=destSize;
destSize=[self getNormalImageSize:destSize];
NSAssert([[self representations] count], @"Bad Input Image...");
NSImage *newImage = [[[NSImage alloc]initWithSize:destSize] autorelease];
[newImage lockFocus];
[self drawInRect:NSMakeRect(0, 0, destSize.width, destSize.height)
fromRect:NSMakeRect(0, 0, self.size.width, self.size.height)
operation:NSCompositeSourceOver fraction:1.0];
[newImage unlockFocus];
[newImage setSize:oldSize];
return newImage;
}
DraggingView Mac OS APP
when you want to use drag
(1)
-(void)_subscribe{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(_draggingConcludedHandler:)
name:DraggingConcludedNotification
object:nil];
}
-(void)_unsubscribe{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
-(void)_draggingConcludedHandler:(NSNotification *)aNotification{
DraggingView *aView = (DraggingView *)[aNotification object];
for (IconImageView *childView in self.childViews){
[childView setTargetImage:[aView targetImage]];
}
}
(2)
#import <Cocoa/Cocoa.h>
/**
* Drag&Drop detecting view fully convered on the main window's content view.
*/
@interface DraggingView : NSView{
NSImage *_targetImage;
BOOL _highlighted;
}
@property (nonatomic, retain) NSImage *targetImage;
@property (nonatomic, assign) BOOL highlighted;
@end
#import "DraggingView.h"
//Private
@interface DraggingView ()
-(void)_setup;
@end
@implementation DraggingView
@synthesize targetImage = _targetImage;
@synthesize highlighted = _highlighted;
-(void)awakeFromNib{
[self registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType, NSTIFFPboardType, nil]];
[self _setup];
}
-(void)drawRect:(NSRect)dirtyRect{
if (_highlighted) {
[[NSColor blueColor] set];
NSFrameRect([self bounds]);
}
}
-(void)dealloc{
self.targetImage = nil;
[super dealloc];
}
#pragma mark -
#pragma mark Accessors
-(void)setHighlighted:(BOOL)yn{
_highlighted = yn;
[self setNeedsDisplay:YES];
}
#pragma mark -
#pragma mark Private
-(void)_setup{
self.highlighted = NO;
}
@end
(1)
-(void)_subscribe{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(_draggingConcludedHandler:)
name:DraggingConcludedNotification
object:nil];
}
-(void)_unsubscribe{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
-(void)_draggingConcludedHandler:(NSNotification *)aNotification{
DraggingView *aView = (DraggingView *)[aNotification object];
for (IconImageView *childView in self.childViews){
[childView setTargetImage:[aView targetImage]];
}
}
(2)
#import <Cocoa/Cocoa.h>
/**
* Drag&Drop detecting view fully convered on the main window's content view.
*/
@interface DraggingView : NSView{
NSImage *_targetImage;
BOOL _highlighted;
}
@property (nonatomic, retain) NSImage *targetImage;
@property (nonatomic, assign) BOOL highlighted;
@end
#import "DraggingView.h"
//Private
@interface DraggingView ()
-(void)_setup;
@end
@implementation DraggingView
@synthesize targetImage = _targetImage;
@synthesize highlighted = _highlighted;
-(void)awakeFromNib{
[self registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType, NSTIFFPboardType, nil]];
[self _setup];
}
-(void)drawRect:(NSRect)dirtyRect{
if (_highlighted) {
[[NSColor blueColor] set];
NSFrameRect([self bounds]);
}
}
-(void)dealloc{
self.targetImage = nil;
[super dealloc];
}
#pragma mark -
#pragma mark Accessors
-(void)setHighlighted:(BOOL)yn{
_highlighted = yn;
[self setNeedsDisplay:YES];
}
#pragma mark -
#pragma mark Private
-(void)_setup{
self.highlighted = NO;
}
@end
Wednesday, February 19, 2014
Webview have request is nil when call createWebViewWithRequest
I meet a problem which weview load link that will get nil
(<a target='_blank' href='http://wangdazhi.blogger.com'> )
- (WebView*)webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request
{
[[sender mainFrame]loadRequest:request];
return sender;
}
After much investigation,I found that the problem was caused by '_blank'.
you can use this method to solve this problem
[webView setPolicyDelegate:self];
- (void)webView:(WebView *)webView decidePolicyForNewWindowAction:(NSDictionary *)actionInformation
request:(NSURLRequest *)request
newFrameName:(NSString *)frameName
decisionListener:(id<WebPolicyDecisionListener>)listener
{
[[myWeb mainFrame] loadRequest:[NSURLRequest requestWithURL:[request URL]]];
}
Tuesday, February 18, 2014
Mac OS Close App after close last window
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender
{
return YES;
}
Sunday, February 16, 2014
Generic RGB Profile Convert sRGB IEC61966-2.1
- (NSBitmapImageRep *)bitmapImageRepByConvertingTosRGBColorSpace {
return [self bitmapImageRepByConvertingToColorSpace:[NSColorSpace sRGBColorSpace]
renderingIntent:NSColorRenderingIntentDefault];
}
- (NSData *)PNGRepresentationInsRGBColorSpace {
return [[self bitmapImageRepByConvertingTosRGBColorSpace] PNGRepresentationAsProgressive:NO];
}
return [self bitmapImageRepByConvertingToColorSpace:[NSColorSpace sRGBColorSpace]
renderingIntent:NSColorRenderingIntentDefault];
}
- (NSData *)PNGRepresentationInsRGBColorSpace {
return [[self bitmapImageRepByConvertingTosRGBColorSpace] PNGRepresentationAsProgressive:NO];
}
Thursday, February 13, 2014
Icon Cooker for Developers using Xcode to build their Mac OS X
Description
Icon Cooker for Developers using Xcode to build their Mac OS X
Icons Cooker has been carefully designed to make it as easy as possible to create and convert icons. All you need to do is drag and drop -Icon Cooker converts the images into icons with only a single click.
● Newest Mac OS X support.
● Very easy to use with slick interface design.
● Create multi-resolution icons in ICNS format with all required resolutions (up to 512x512@2x)
● Drag'n'drop support, drag any file from Finder, dragging and rescaling between different resolutions
● Icon Cooker can automatically generate icons provisions comply with apple’s OS X Human Interface Guidelines
Download Link
https://itunes.apple.com/us/app/icon-cooker/id820946234?mt=12
performSelectorOnMainThread 使用
[self performSelectorOnMainThread:@selector(convertDidFinished:) withObject:iconPath waitUntilDone:NO];
- (void)convertDidFinished:(NSString *) outputPath
{
}
- (void)convertDidFinished:(NSString *) outputPath
{
}
Tuesday, February 11, 2014
URL Web to PDF Mac
URL WEB To PDF lets you make a webpage to PDF file and access it anytime. Now you can share or view your PDF anytime offline with this webpage converter.
How to use
(1)Enter any url
(2)Wait for the page is fully loaded
(3) click "Convert to PDF". Your page will be exported to PDF.
Benefits of WEB To PDF conversion
- Save articles to simply read them later
- Access important information without an Internet connection
- Record any web content in case it becomes unavailable
- Eliminate the problem of broken bookmarks
- Share PDFs with family or partners
- Be sure the recipients see the information the same way it was displayed in your browser
- PDF documents have a consistent appearance on any system or device
Downdload Link
https://itunes.apple.com/us/app/url-web-to-pdf/id820017965?mt=12
How to use
(1)Enter any url
(2)Wait for the page is fully loaded
(3) click "Convert to PDF". Your page will be exported to PDF.
Benefits of WEB To PDF conversion
- Save articles to simply read them later
- Access important information without an Internet connection
- Record any web content in case it becomes unavailable
- Eliminate the problem of broken bookmarks
- Share PDFs with family or partners
- Be sure the recipients see the information the same way it was displayed in your browser
- PDF documents have a consistent appearance on any system or device
Downdload Link
https://itunes.apple.com/us/app/url-web-to-pdf/id820017965?mt=12
Subscribe to:
Posts (Atom)