- 浏览: 207493 次
- 性别:
- 来自: 杭州
文章分类
最新评论
-
落叶知秋__:
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 2086碰到比较长的赋值怎么办 可以这么写 输出结果 a = ... -
KissXML 简易教程
2010-03-26 23:04 1737文章来源 http://ixhan.com/2010/03 ... -
永远的扫雷英雄(开源)
2009-12-25 22:10 1561源码请移步: http://github.com/xhan ... -
admob备忘
2009-12-09 20:57 1357使用很简单,备忘下避免下次使用又得去长长的readme里面找. ... -
小东西没我想象中简单
2009-11-11 00:15 1089贴个资料备忘。 这两天在研究用JAVA开发类似M ... -
原来UIView Animation 可以这么写(看错咯)
2009-11-09 17:26 6570之前受某人影响以为一连串的UIView Animation 只 ... -
iPhone simulator 在屏幕消失
2009-11-09 10:36 1046打开 iPhone simulator 后无法在屏幕中找到。。 ... -
QQ - iPhone 风格的好友列表实现
2009-09-22 17:04 2585// // QQstyleTableViewViewCon ... -
UITableView 删除特定的CELL
2009-09-17 23:42 3250使用的函数: [self.tableView deleteR ... -
UIVIEW调试的遗漏
2009-09-16 15:56 1072今天被一个小问题折腾了2小时。 事情是这样的 VC.vew ... -
UIKIT 相对坐标系统
2009-09-15 23:51 1351今天项目中设计了这么个流程: mainView < ... -
NIB文件读取数据方法
2009-09-11 16:05 1814从COOKBOOK 上学到一招: 如果仅仅需要一个VIEW ... -
ViewController 的奇怪问题
2009-09-08 16:14 904今天项目中出现奇怪问题 , 在某 viewContro ... -
优化 scrollView 性能(tableView)
2009-09-04 12:24 2052曾经尝试各种方法优化滚动视图的性能,都没什么好的效果。 今天 ... -
解决升级到Snow Leopard 后无法连接 iPhone
2009-08-19 14:51 1162重新安装下AppleMobileDeviceSupport 就 ... -
Tips For Using Xcode
2009-08-18 18:09 1276VIA http://www.mobileorchard.co ... -
Three20 教程和模板
2009-08-07 22:53 5179Three20 是在Facebook 的 iPhone 程序剥 ... -
objc 实现类变量
2009-07-29 23:22 1610从HTTPRiot 源码学习而来。 看到 mergedOpt ... -
解决mac上一个傻问题:command not found
2009-07-23 19:37 3547XCODE 在使用SVN上曾经出现这个错误 sudo ssh ... -
一些iphone开发资源
2009-07-23 10:24 1242HTTPRiot - A simple HTTP REST L ...
相关推荐
在iOS开发中,Xcode是Apple官方推荐的集成开发环境(IDE),用于编写Objective-C或Swift的代码。针对iOS开发者,提升工作效率是非常重要的,而Xcode插件则可以帮助我们实现这一点。本文将介绍一个名为“getterMake-...
Xcode作为Apple的官方集成开发环境(IDE),提供了丰富的功能,其中之一就是自动化注释的生成。标题提到的"Xcode自动给方法添加注释",实际上是在讨论Xcode的一个插件——VVDocumenter,这个插件可以方便地帮助...
如果XcodeSetting.json的功能不能满足特定需求,可以直接修改publish/ios/tools下的XcodeProjectSetting源码并生成可执行的XcodeSetting.exe。 该工具支持以下功能: 1. Info.plist编辑:可以编辑应用程序的元数据...
在Xcode项目中,自动增加Build属性通常涉及在构建设置(Build Settings)中添加自定义脚本。根据给定文件内容,其中提到了关键的脚本命令“xcrun agvtool next-version -all”,这是一个在命令行中运行的命令,属于...
在iOS开发领域,Xcode是Apple官方推荐的集成开发环境(IDE),它为开发者提供了丰富的功能,其中之一就是自动添加注释。"Xcode自动添加注释"这一特性大大提升了编码效率,使得源代码的可读性和维护性得到显著提高。...
本文将详细介绍“XCODE自动编译生成IPA脚本”这一主题,并解释如何利用提供的`run.sh`脚本来实现这一目标。 首先,`run.sh`是一个bash shell脚本,通常用于在终端中执行一系列命令,以实现自动化任务。在这个场景下...
标题中的“Python-xCode自动化构建工具”指的是使用Python语言与xCode集成,实现iOS应用程序的自动化构建过程。在iOS开发中,xCode是主要的集成开发环境(IDE),而Python则可以作为强大的脚本语言来扩展xCode的功能...
在iOS和macOS应用开发领域,Xcode是Apple官方推荐的集成开发环境(IDE),它提供了丰富的功能,如代码编辑、调试、构建管理等。然而,对于习惯于使用Visual Studio等其他IDE的开发者来说,Xcode在某些方面可能略显...
iOS 自动化打包脚本,并上传*ipa*文件至蒲公英。参数说明: ``` Usage: autobuild.py [options] Options: -h, --help show this help message and exit -w name.xcworkspace, --workspace=name.xcworkspace ...
总结一下,VVDocumenter-Xcode是一款强大的Xcode插件,它提供了自动注释生成、快捷键操作和智能感知等功能,大大简化了Swift和Objective-C的文档编写工作,提升了代码的可读性和团队协作效率。通过简单的安装步骤和...
这里,`<配置文件路径>/Info.plist`是包含导出选项的属性列表文件,`<归档文件路径>`是之前归档步骤中生成的.xcarchive文件路径,`导出路径>`是最终导出的IPA文件存放路径,而`<发布证书名称>`是与你的归档项目关联...
Xcode自动注释插件是开发iOS和macOS应用程序时非常实用的工具,它能够帮助开发者快速、方便地为代码添加注释。VVDocumenter-Xcode是其中一款广受欢迎的插件,它使得遵循Apple的Swift或Objective-C编程规范来编写文档...
该工具的核心功能在于其自动注释块生成能力,通过在代码行前输入"///",即可自动生成符合约定的注释结构。这种便捷的方式可以节省程序员大量的时间,让他们更专注于代码逻辑本身,而非繁琐的文档编写。在Xcode中,...
4)com.cn.cooxin包,admin包主要是管理代码生成后台功能的文件,包含用户的管理、角色菜单管理,代码生成管理等,code包主要是代码生成相关的功能,common包是公共服务相关的功能,ueditor是百度编辑器相关的功能...
而Xcode 9引入的这个脚本,则可以自动化这个过程,确保生成的图标满足苹果的全分辨率要求。 脚本的核心功能在于生成适配不同设备和显示比例的图标。在iOS中,由于存在iPhone、iPad、iPod Touch等多种设备,且有...
在iOS开发中,Xcode6引入了一项革命性的特性,那就是自动布局(Auto Layout),它极大地简化了界面设计,特别是对于适配不同屏幕尺寸的移动应用。本篇将深入探讨Xcode6中的自动布局,以及如何将其应用于UIScrollView...
在Xcode中,当你选中一个函数名称时,按下设定的快捷键“Command + option + /”,Xcode会自动生成对应的注释模板。这个模板应该根据你的编程习惯和项目需求进行定制,以便更好地满足注释的要求。 注释的质量直接...
《Xcode文件引用自动添加工具——XUPorter深度解析》 在iOS应用开发中,Xcode是不可或缺的集成开发环境。然而,当我们在Unity中完成游戏开发并导出到iOS平台时,需要手动处理一系列的Xcode项目设置,包括添加必要的...
在iOS开发过程中,Xcode是苹果官方推荐的集成开发环境(IDE),它包含了代码编辑、构建管理、调试等多种功能。然而,Xcode的频繁更新有时会导致开发者安装的第三方插件失效,这无疑增加了开发者的困扰。针对这个问题...
Xcode自动签名其他app的脚本软件,可以快速修改签名信息,完成重签名