- 浏览: 203307 次
- 性别:
- 来自: 杭州
文章分类
最新评论
-
落叶知秋__:
indexPath能用?
UITableView 删除特定的CELL -
xhanxhanxhan:
Hooopo 写道puts 返回结果是nilnil and r ...
一个脚本×关键词“百度说吧”你懂的 -
Hooopo:
puts 返回结果是nilnil and return 这个是 ...
一个脚本×关键词“百度说吧”你懂的 -
nono123:
谢谢!
不用信用卡而申請其他地區itunes賬號的方法 -
BarryWei:
lordhong 写道多谢分享, 学习一下, iPhone我都 ...
永远的扫雷英雄(开源)
一次偶然机会从git上找到,可惜没有添加关注。现在忘记从哪里clone 出来了。
应该是目前最好用的自动补上属性
@property()xx
@syn
delloc
功能。
代码 写道
#! /usr/bin/perl -w
# Created by Matt Gallagher on 20/10/08.
# Copyright 2008 Matt Gallagher. All rights reserved.
#
# Permission is given to use this source code file without charge in any
# project, commercial or otherwise, entirely at your risk, with the condition
# that any redistribution (in part or whole) of source code must retain
# this copyright and permission notice. Attribution in compiled projects is
# appreciated but not required.
use strict;
# Get the header file contents from Xcode user scripts
my $headerFileContents = <<'HEADERFILECONTENTS';
%%%{PBXAllText}%%%
HEADERFILECONTENTS
# Get the indices of the selection from Xcode user scripts
my $selectionStartIndex = %%%{PBXSelectionStart}%%%;
my $selectionEndIndex = %%%{PBXSelectionEnd}%%%;
# Get path of the header file
my $implementationFilePath = "%%%{PBXFilePath}%%%";
my $headerFilePath = $implementationFilePath;
# Look for an implemenation file with a ".m" or ".mm" extension
$implementationFilePath =~ s/\.[hm]*$/.m/;
if (!(-e $implementationFilePath))
{
$implementationFilePath =~ s/.m$/.mm/;
}
# Handle subroutine to trime whitespace off both ends of a string
sub trim
{
my $string = shift;
$string =~ s/^\s*(.*?)\s*$/$1/;
return $string;
}
# Get the selection out of the header file
my $selectedText = substr $headerFileContents, $selectionStartIndex, ($selectionEndIndex - $selectionStartIndex);
$selectedText = trim $selectedText;
my $selectedLine;
foreach $selectedLine (split(/\n+/, $selectedText)) {
my $type = "";
my $asterisk = "";
my $name = "";
my $ivarName = "";
my $behavior = "";
my $isPointer = 0;
# Test that the selection is:
# At series of identifiers (the type name and access specifiers)
# Possibly an asterisk
# Another identifier (the variable name)
# A semi-colon
if (length($selectedLine) && ($selectedLine =~ /([_A-Za-z][_A-Za-z0-9]*\s*)+([\s\*]+)([_A-Za-z][_A-Za-z0-9]*);/))
{
$type = $1;
$type = trim $type;
$asterisk = $2;
$asterisk = trim $asterisk;
$ivarName = $3;
if ($ivarName =~ /^_(.*)/) {
$name = $1;
}
else {
$name = $ivarName;
}
$behavior = "";
if (defined($asterisk) && length($asterisk) == 1)
{
$isPointer = 1;
if ($type eq "NSArray" || $type eq "NSString" || $type eq "NSDictionary" || $type eq "NSSet") {
$behavior = "(nonatomic, copy) ";
}
else
{
$behavior = "(nonatomic, retain) ";
}
}
else
{
$isPointer = 0;
$behavior = "(nonatomic, assign) ";
$asterisk = "";
}
}
else
{
next;
}
# Find the closing brace (end of the class variables section)
my $remainderOfHeader = substr $headerFileContents, $selectionEndIndex;
my $indexAfterClosingBrace = $selectionEndIndex + index($remainderOfHeader, "\n}\n") + 3;
if ($indexAfterClosingBrace == -1)
{
exit 1;
}
# Determine if we need to add a newline in front of the property declaration
my $leadingNewline = "\n";
if (substr($headerFileContents, $indexAfterClosingBrace, 1) eq "\n")
{
$indexAfterClosingBrace += 1;
$leadingNewline = "";
}
# Determine if we need to add a newline after the property declaration
my $trailingNewline = "\n";
if (substr($headerFileContents, $indexAfterClosingBrace, 9) eq "\@property")
{
$trailingNewline = "";
}
# Create and insert the propert declaration
my $propertyDeclaration = $leadingNewline . "\@property " . $behavior . $type . " " . $asterisk . $name . ";\n" . $trailingNewline;
substr($headerFileContents, $indexAfterClosingBrace, 0) = $propertyDeclaration;
my $replaceFileContentsScript = <<'REPLACEFILESCRIPT';
on run argv
set fileAlias to POSIX file (item 1 of argv)
set newDocText to (item 2 of argv)
tell application "Xcode"
set doc to open fileAlias
set text of doc to newDocText
end tell
end run
REPLACEFILESCRIPT
# Use Applescript to replace the contents of the header file
# (I could have used the "Output" of the Xcode user script instead)
system 'osascript', '-e', $replaceFileContentsScript, $headerFilePath, $headerFileContents;
# Stop now if the implementation file can't be found
if (!(-e $implementationFilePath))
{
exit 1;
}
my $getFileContentsScript = <<'GETFILESCRIPT';
on run argv
set fileAlias to POSIX file (item 1 of argv)
tell application "Xcode"
set doc to open fileAlias
set docText to text of doc
end tell
return docText
end run
GETFILESCRIPT
# Get the contents of the implmentation file
open(SCRIPTFILE, '-|') || exec 'osascript', '-e', $getFileContentsScript, $implementationFilePath;
my $implementationFileContents = do {local $/; <SCRIPTFILE>};
close(SCRIPTFILE);
# Look for the class implementation statement
if (length($implementationFileContents) && ($implementationFileContents =~ /(\@implementation [_A-Za-z][_A-Za-z0-9]*\n)/))
{
my $matchString = $1;
my $indexAfterMatch = index($implementationFileContents, $matchString) + length($matchString);
# Determine if we want a newline before the synthesize statement
$leadingNewline = "\n";
if (substr($implementationFileContents, $indexAfterMatch, 1) eq "\n")
{
$indexAfterMatch += 1;
$leadingNewline = "";
}
# Determine if we want a newline after the synthesize statement
$trailingNewline = "\n";
if (substr($implementationFileContents, $indexAfterMatch, 11) eq "\@synthesize")
{
$trailingNewline = "";
}
# Create and insert the synthesize statement
my $synthesizeStatement;
if ($ivarName ne $name) {
$synthesizeStatement = $leadingNewline . "\@synthesize " . $name . " = " . $ivarName . ";\n" . $trailingNewline;
}
else {
$synthesizeStatement = $leadingNewline . "\@synthesize " . $name . ";\n" . $trailingNewline;
}
substr($implementationFileContents, $indexAfterMatch, 0) = $synthesizeStatement;
if ($isPointer) {
if ($implementationFileContents !~ s#(\(void\)\s*dealloc\s*\{\s*\n)(\s*)#$1$2\[$ivarName release\], $ivarName = nil;\n$2#s) {
$implementationFileContents =~ s#(\@end)#\n- (void)dealloc {\n\t[$ivarName release], $ivarName = nil;\n\t[super dealloc];\n}\n$1#s;
}
}
# Use Applescript to replace the contents of the implementation file in Xcode
system 'osascript', '-e', $replaceFileContentsScript, $implementationFilePath, $implementationFileContents;
}
}
exit 0;
# Created by Matt Gallagher on 20/10/08.
# Copyright 2008 Matt Gallagher. All rights reserved.
#
# Permission is given to use this source code file without charge in any
# project, commercial or otherwise, entirely at your risk, with the condition
# that any redistribution (in part or whole) of source code must retain
# this copyright and permission notice. Attribution in compiled projects is
# appreciated but not required.
use strict;
# Get the header file contents from Xcode user scripts
my $headerFileContents = <<'HEADERFILECONTENTS';
%%%{PBXAllText}%%%
HEADERFILECONTENTS
# Get the indices of the selection from Xcode user scripts
my $selectionStartIndex = %%%{PBXSelectionStart}%%%;
my $selectionEndIndex = %%%{PBXSelectionEnd}%%%;
# Get path of the header file
my $implementationFilePath = "%%%{PBXFilePath}%%%";
my $headerFilePath = $implementationFilePath;
# Look for an implemenation file with a ".m" or ".mm" extension
$implementationFilePath =~ s/\.[hm]*$/.m/;
if (!(-e $implementationFilePath))
{
$implementationFilePath =~ s/.m$/.mm/;
}
# Handle subroutine to trime whitespace off both ends of a string
sub trim
{
my $string = shift;
$string =~ s/^\s*(.*?)\s*$/$1/;
return $string;
}
# Get the selection out of the header file
my $selectedText = substr $headerFileContents, $selectionStartIndex, ($selectionEndIndex - $selectionStartIndex);
$selectedText = trim $selectedText;
my $selectedLine;
foreach $selectedLine (split(/\n+/, $selectedText)) {
my $type = "";
my $asterisk = "";
my $name = "";
my $ivarName = "";
my $behavior = "";
my $isPointer = 0;
# Test that the selection is:
# At series of identifiers (the type name and access specifiers)
# Possibly an asterisk
# Another identifier (the variable name)
# A semi-colon
if (length($selectedLine) && ($selectedLine =~ /([_A-Za-z][_A-Za-z0-9]*\s*)+([\s\*]+)([_A-Za-z][_A-Za-z0-9]*);/))
{
$type = $1;
$type = trim $type;
$asterisk = $2;
$asterisk = trim $asterisk;
$ivarName = $3;
if ($ivarName =~ /^_(.*)/) {
$name = $1;
}
else {
$name = $ivarName;
}
$behavior = "";
if (defined($asterisk) && length($asterisk) == 1)
{
$isPointer = 1;
if ($type eq "NSArray" || $type eq "NSString" || $type eq "NSDictionary" || $type eq "NSSet") {
$behavior = "(nonatomic, copy) ";
}
else
{
$behavior = "(nonatomic, retain) ";
}
}
else
{
$isPointer = 0;
$behavior = "(nonatomic, assign) ";
$asterisk = "";
}
}
else
{
next;
}
# Find the closing brace (end of the class variables section)
my $remainderOfHeader = substr $headerFileContents, $selectionEndIndex;
my $indexAfterClosingBrace = $selectionEndIndex + index($remainderOfHeader, "\n}\n") + 3;
if ($indexAfterClosingBrace == -1)
{
exit 1;
}
# Determine if we need to add a newline in front of the property declaration
my $leadingNewline = "\n";
if (substr($headerFileContents, $indexAfterClosingBrace, 1) eq "\n")
{
$indexAfterClosingBrace += 1;
$leadingNewline = "";
}
# Determine if we need to add a newline after the property declaration
my $trailingNewline = "\n";
if (substr($headerFileContents, $indexAfterClosingBrace, 9) eq "\@property")
{
$trailingNewline = "";
}
# Create and insert the propert declaration
my $propertyDeclaration = $leadingNewline . "\@property " . $behavior . $type . " " . $asterisk . $name . ";\n" . $trailingNewline;
substr($headerFileContents, $indexAfterClosingBrace, 0) = $propertyDeclaration;
my $replaceFileContentsScript = <<'REPLACEFILESCRIPT';
on run argv
set fileAlias to POSIX file (item 1 of argv)
set newDocText to (item 2 of argv)
tell application "Xcode"
set doc to open fileAlias
set text of doc to newDocText
end tell
end run
REPLACEFILESCRIPT
# Use Applescript to replace the contents of the header file
# (I could have used the "Output" of the Xcode user script instead)
system 'osascript', '-e', $replaceFileContentsScript, $headerFilePath, $headerFileContents;
# Stop now if the implementation file can't be found
if (!(-e $implementationFilePath))
{
exit 1;
}
my $getFileContentsScript = <<'GETFILESCRIPT';
on run argv
set fileAlias to POSIX file (item 1 of argv)
tell application "Xcode"
set doc to open fileAlias
set docText to text of doc
end tell
return docText
end run
GETFILESCRIPT
# Get the contents of the implmentation file
open(SCRIPTFILE, '-|') || exec 'osascript', '-e', $getFileContentsScript, $implementationFilePath;
my $implementationFileContents = do {local $/; <SCRIPTFILE>};
close(SCRIPTFILE);
# Look for the class implementation statement
if (length($implementationFileContents) && ($implementationFileContents =~ /(\@implementation [_A-Za-z][_A-Za-z0-9]*\n)/))
{
my $matchString = $1;
my $indexAfterMatch = index($implementationFileContents, $matchString) + length($matchString);
# Determine if we want a newline before the synthesize statement
$leadingNewline = "\n";
if (substr($implementationFileContents, $indexAfterMatch, 1) eq "\n")
{
$indexAfterMatch += 1;
$leadingNewline = "";
}
# Determine if we want a newline after the synthesize statement
$trailingNewline = "\n";
if (substr($implementationFileContents, $indexAfterMatch, 11) eq "\@synthesize")
{
$trailingNewline = "";
}
# Create and insert the synthesize statement
my $synthesizeStatement;
if ($ivarName ne $name) {
$synthesizeStatement = $leadingNewline . "\@synthesize " . $name . " = " . $ivarName . ";\n" . $trailingNewline;
}
else {
$synthesizeStatement = $leadingNewline . "\@synthesize " . $name . ";\n" . $trailingNewline;
}
substr($implementationFileContents, $indexAfterMatch, 0) = $synthesizeStatement;
if ($isPointer) {
if ($implementationFileContents !~ s#(\(void\)\s*dealloc\s*\{\s*\n)(\s*)#$1$2\[$ivarName release\], $ivarName = nil;\n$2#s) {
$implementationFileContents =~ s#(\@end)#\n- (void)dealloc {\n\t[$ivarName release], $ivarName = nil;\n\t[super dealloc];\n}\n$1#s;
}
}
# Use Applescript to replace the contents of the implementation file in Xcode
system 'osascript', '-e', $replaceFileContentsScript, $implementationFilePath, $implementationFileContents;
}
}
exit 0;
配置
1.添加到自定义脚本中。
2.INPUT: ENTIRE DOC
3.DIRECTORY:HOME
4.OUTPUT:DISCARD
5.ERRORS:IGNORE
使用:
选中需要生成属性的内容,运行脚本。
enjoy!
评论
6 楼
xhanxhanxhan
2009-10-10
gakaki 写道
我是说你可以自己编写
对你回复真无语。
我发帖子是干嘛的?
5 楼
gakaki
2009-10-09
我是说你可以自己编写
4 楼
xhanxhanxhan
2009-10-08
gakaki 写道
snippet功能还属textmate最强
有个iphone tmbundle的github
有个iphone tmbundle的github
完全没这个功能。
这个bundle 只提供了对 iPhone class 的高亮 和代码提示。
3 楼
xhanxhanxhan
2009-10-04
gakaki 写道
snippet功能还属textmate最强
有个iphone tmbundle的github
有个iphone tmbundle的github
找到了。看看好用否。
2 楼
gakaki
2009-10-04
snippet功能还属textmate最强
有个iphone tmbundle的github
有个iphone tmbundle的github
1 楼
lordhong
2009-10-01
这个还挺有趣的!
发表评论
-
NSString另类赋值方法
2011-01-05 10:56 2051碰到比较长的赋值怎么办 可以这么写 输出结果 a = ... -
KissXML 简易教程
2010-03-26 23:04 1698文章来源 http://ixhan.com/2010/03 ... -
永远的扫雷英雄(开源)
2009-12-25 22:10 1520源码请移步: http://github.com/xhan ... -
admob备忘
2009-12-09 20:57 1330使用很简单,备忘下避免下次使用又得去长长的readme里面找. ... -
小东西没我想象中简单
2009-11-11 00:15 1061贴个资料备忘。 这两天在研究用JAVA开发类似M ... -
原来UIView Animation 可以这么写(看错咯)
2009-11-09 17:26 6541之前受某人影响以为一连串的UIView Animation 只 ... -
iPhone simulator 在屏幕消失
2009-11-09 10:36 1016打开 iPhone simulator 后无法在屏幕中找到。。 ... -
QQ - iPhone 风格的好友列表实现
2009-09-22 17:04 2535// // QQstyleTableViewViewCon ... -
UITableView 删除特定的CELL
2009-09-17 23:42 3210使用的函数: [self.tableView deleteR ... -
UIVIEW调试的遗漏
2009-09-16 15:56 1019今天被一个小问题折腾了2小时。 事情是这样的 VC.vew ... -
UIKIT 相对坐标系统
2009-09-15 23:51 1317今天项目中设计了这么个流程: mainView < ... -
NIB文件读取数据方法
2009-09-11 16:05 1761从COOKBOOK 上学到一招: 如果仅仅需要一个VIEW ... -
ViewController 的奇怪问题
2009-09-08 16:14 869今天项目中出现奇怪问题 , 在某 viewContro ... -
优化 scrollView 性能(tableView)
2009-09-04 12:24 2020曾经尝试各种方法优化滚动视图的性能,都没什么好的效果。 今天 ... -
解决升级到Snow Leopard 后无法连接 iPhone
2009-08-19 14:51 1110重新安装下AppleMobileDeviceSupport 就 ... -
Tips For Using Xcode
2009-08-18 18:09 1251VIA http://www.mobileorchard.co ... -
Three20 教程和模板
2009-08-07 22:53 5140Three20 是在Facebook 的 iPhone 程序剥 ... -
objc 实现类变量
2009-07-29 23:22 1575从HTTPRiot 源码学习而来。 看到 mergedOpt ... -
解决mac上一个傻问题:command not found
2009-07-23 19:37 3494XCODE 在使用SVN上曾经出现这个错误 sudo ssh ... -
一些iphone开发资源
2009-07-23 10:24 1214HTTPRiot - A simple HTTP REST L ...
相关推荐
xcode自动给代码添加注释,下载zip后解压,运行工程,成功后重启xcode(command+q)
功能:批量生成属性的懒加载 getter 应用场景 :手写ui代码可以批量生成 github地址:https://github.com/hackxhj/getterMake-Xcode
所以unity代码或者资源没有改变并且需要打多个渠道或者不同参数的渠道包的时候,只需要导出一次xcode工程即可,通过外部的自动配置工具进行xcode工程的各种
Xcode根据编译次数自动增加Build值 【相关资源只为技术交流】
xCode自动化构建工具
用xcode打开里面的程序,运行,关闭xcode再打开xcode。 当在文件中输入“///”时,系统会自动为代码添加注释的。
iOS 自动化打包脚本,并上传*ipa*文件至蒲公英。参数说明: ``` Usage: autobuild.py [options] Options: -h, --help show this help message and exit -w name.xcworkspace, --workspace=name.xcworkspace ...
xcode缺少想visual studio开发环境的快速自动对其命令,这个插件可以帮助你
VVDocument Xcode 自动注释插件 直接编译 重启xcode即可
4)com.cn.cooxin包,admin包主要是管理代码生成后台功能的文件,包含用户的管理、角色菜单管理,代码生成管理等,code包主要是代码生成相关的功能,common包是公共服务相关的功能,ueditor是百度编辑器相关的功能...
Xcode自动注释插件,下载压缩包,然后在Xcode工程里打开该项目,然后build,重启Xcode
将本脚本放到您的IOS项目里,cd到项目里,然后执行./run 项目名。然后项目就会自动编译-》xcarchive-》输出ipa到 output文件夹
运行该工具后重启xcode 使用 /// 将自动生成注释块
分享 如何命令打包生成 ipa, 以及解决存在的坑,如出现xcodebuild: error: inv)lid option '-exportForm)的报错, 分享解决
Xcode自动签名其他app的脚本软件,可以快速修改签名信息,完成重签名
iOS xcode自动打包上传appstroe脚本代码,只需要配置开发者账号密码,证书名称
完全自动打包ipa包,只需要改路径和签名。简单、方便!
一个Xcode源代码编辑器扩展,可以对您的代码注释进行拼写检查和自动更正
1. 先完全关闭xcode 之后 打开工程 运行 , 之后重启xcode 提示点击loadBundle 2.生成 点击 file ---- imageAsstes ---- setting 设置所需图片类型 之后 generate Missing Assetes 完成生成
一个自动生成CodingKeys的Xcode9 扩展