할 수 있는 방법을 자동으로 추가 특성하는 것을 목적으?
-
02-07-2019 - |
문제
추가 새로운 특성을 클래스,나 자신도 같은 일을 입력해 xcode 에서:
add TYPE *NAME;
(습니다.서 인터페이스)add @property (nonatomic, retain) TYPE *NAME;
(습니다.h)add @synthesize NAME;
(습니다.m)add [NAME release];
(습니다.m dealloc)
(나는 비 쓰레기 수집한 환경을 제공합니다.)
이렇게 하려면 어떻게 해야 합니까 자동으로?
해결책
는 권리에 대한 소리.IIRC,Objective-C2.0doc 를 떠날 수 밖으로 1 단계이지만,그렇지 않으면 모르겠는 모든 바로 가기입니다.
당신은 아마 쓰는 사용자가 스크립트를 그렇게 안에 Xcode.보 http://www.mactech.com/articles/mactech/Vol.23/23.01/2301XCode/index.html.
다른 팁
에 따르면 개발자 문서 에서 64 비트 런타임을 남겨둘 수 있습 단계 1.
당신이 볼 수있는 앤드류 팡의 RMModelObject -나는 그것을 사용하지 않은,그러나 그것을 행동으로 객체의 기본 클래스는 단순화 모형 창조이다.
나는 그것을 사용하지 않은,그러나 여기에 몇 가지 무엇의 강조 표시된 추가 정보:
- 을 선언할 필요가 없 인스턴스의 변수,
- 를 작성할 필요가 없습니다 접근법
- 무료 NSCopying 프로토콜 지원(
-copyWithZone:
),- 무료 NSCoding 프로토콜 지원(
-initWithCoder:
,-encodeWithCoder:
),- 무료
-isEqual:
고시`구현- 를 작성할 필요가 없습니다
-dealloc
대부분의 경우에 있습니다.
여기에서 다른 솔루션 내에서 수정 이 문서 (도 초기 기사)
버전에 블로그를 찾는 외부 변수의 변수를 선언하 블록과 일치하는 방법을 이름은 너무입니다.I have done a 원유를 수정하는 유일한 검색에 대한 변수하기 전에 처음'}'.이것이 휴식을 여러 개 있는 경우에는 인터페이스 선언을 헤더에 파일입니다.
나는 설정 출력하"대체하는 문서 Conents"입력으로"전체"문서 ....
#!/usr/bin/python
thisfile = '''%%%{PBXFilePath}%%%'''
code = '''%%%{PBXAllText}%%%'''
selmark = '''%%%{PBXSelection}%%%'''
import re
if thisfile.endswith('.h'):
variableEnd = code.find('\n', code.find('}'))
properties = []
memre = re.compile('\s+(?:IBOutlet)?\s+([^\-+@].*? \*?.*?;)')
for match in memre.finditer(code[:variableEnd]):
member = match.group(1)
retain = member.find('*') != -1 and ', retain' or ''
property = '@property (nonatomic%s) %s' % (retain,member)
if code.find(property) == -1:
properties.append(property)
if properties:
print '%s\n\n%s%s%s%s' % (code[:variableEnd],selmark,'\n'.join(properties),selmark,code[variableEnd:])
elif thisfile.endswith('.m'):
headerfile = thisfile.replace('.m','.h')
properties = []
retains = []
propre = re.compile('@property\s\((.*?)\)\s.*?\s\*?(.*?);')
header = open(headerfile).read()
for match in propre.finditer(header):
if match.group(1).find('retain') != -1:
retains.append(match.group(2))
property = '@synthesize %s;' % match.group(2)
if code.find(property) == -1:
properties.append(property)
pindex = code.find('\n', code.find('@implementation'))
if properties and pindex != -1:
output = '%s\n\n%s%s%s' % (code[:pindex],selmark,'\n'.join(properties),selmark)
if retains:
dindex = code.find('\n', code.find('(void)dealloc'))
output += code[pindex:dindex]
retainsstr = '\n\t'.join(['[%s release];' % retain for retain in retains])
output += '\n\t%s' % retainsstr
pindex = dindex
output += code[pindex:]
print output
가 있 케빈 러 s Accessorizer.에서 웹 페이지:
Accessorizer 선택하는 적절한 속성 지정자에 따라 ivar 유형 -도 생성할 수 있습 명시적 접근(1.0)을 자동적으로...지 Accessorizer 는 훨씬,훨씬 더 많은...