Ksimagenamed is a plug-in that enables xcode to preview images in projects.Code [nsimage imagenamed:. xcode automatically lists the images in the project and provides the preview function.
The Project address is https://github.com/ksuther/KSImageNamed-Xcode.
However, in projects, users often use macro definitions such as uiimagenamed (nsstring * name) and uiimageload (name, type). I prefer to use these macro definition files, can we automatically prompt when writing the code uiimagenamed (if not, I will not write this article)? Well, let's see how I did it:
You may also notice that the keyword file configured in this project is completions. plist. The Code is as follows:
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><array> <dict> <key>classAndMethod</key> <string>mage imageNamed:</string> <key>methodDeclaration</key> <string> imageNamed:</string> <key>methodName</key> <string>imageNamed</string> <key>comment</key> <string>Standard NSImage/UIImage method</string> </dict> <dict> <key>classAndMethod</key> <string>prite spriteWithFile:</string> <key>methodDeclaration</key> <string> spriteWithFile:</string> <key>methodName</key> <string>spriteWithFile</string> <key>comment</key> <string>cocos2d's CCSprite</string> </dict> <dict> <key>classAndMethod</key> <string>priteFrame frameWithImageNamed:</string> <key>methodDeclaration</key> <string> frameWithImageNamed:</string> <key>methodName</key> <string>frameWithImageNamed</string> <key>comment</key> <string>cocos2d's CCSpriteFrame</string> </dict> <dict> <key>classAndMethod</key> <string>ode spriteNodeWithImageNamed:</string> <key>methodDeclaration</key> <string> spriteNodeWithImageNamed:</string> <key>methodName</key> <string>spriteNodeWithImageNamed</string> <key>comment</key> <string>SpriteKit's sprite node</string> </dict> <dict> <key>classAndMethod</key> <string>ure textureWithImageNamed:</string> <key>methodDeclaration</key> <string> textureWithImageNamed:</string> <key>methodName</key> <string>textureWithImageNamed</string> <key>comment</key> <string>SpriteKit's SKTexture</string> </dict></array></plist>
Before </array>, add
<dict> <key>classAndMethod</key> <string>UIImageNamed(</string> <key>methodDeclaration</key> <string>(</string> <key>methodName</key> <string>UIImageNamed</string> <key>comment</key> <string>Custom UIImageName method</string> </dict> <dict> <key>classAndMethod</key> <string>UIImageLoad(</string> <key>methodDeclaration</key> <string>(</string> <key>methodName</key> <string>UIImageLoad</string> <key>comment</key> <string>Custom UIImageLoad method</string> </dict>
Save, run the project, and restart xcode. Now we can customize the method. If you use another macro definition, you can add configuration information according to this method.
Xcode6 automatically prompts that the image ksimagenamed supports the custom uiimagenamed (name) and uiimageload (name, type) methods.