任何人對於如何能夠在課堂中突出顯示ivar並擊中按鍵並插入屬性並在適當位置將代碼合成到我的代碼中,都有很好的指導?我一直這樣做了一段時間,並輸入那些樣板文件有時會讓我感到緊張。適用於iPhone的XCode宏
2
A
回答
1
0
爲了這個,我在Ruby中敲出了一些快速和骯髒的腳本。他們只是對選擇進行操作並將結果放在剪貼板上。
物業declerations:
#! /usr/bin/env ruby -w
r=/^\s*(.*;)/
inputLines=STDIN.read
inputLines.each do |l|
l.strip!
m=l.match(r)
if m
if m[0].index("*")
puts "@property(nonatomic, retain) " + m[0]
elsif m[0].index(/^\s*id\s/)
puts "@property(nonatomic, retain) " + m[0]
else
puts "@property " + m[0]
end
end
end
這原來... 的NSString * ASTRING;
...到:
@property(nonatomic, retain) NSString *aString;
這個腳本轉向伊娃的@synthesize:
#! /usr/bin/env ruby -w
r=/\s*\w+\s+\**(\w+\s*);/
s=STDIN.read
s.each_line() do |l|
l.strip!
m=l.match(r)
if m
puts "@synthesize " +m.captures[0]+";"
end
end
腳本來完成這一切一氣呵成要求AppleScript的,給了我一個皮疹。我堅持KISS。
+0
沒有比單個操作更簡單的...不需要純粹的Applescript。 – 2010-02-03 00:12:24
相關問題
- 1. Xcode 3.2.6適用於iPhone iOS 5 beta 6?
- 2. 構建適用於iPhone的iOS應用程序適用於xCode,但不適用於命令行(xcodebuild)
- 3. API適用於iPhone
- 4. UISplitViewController適用於iphone
- 5. 適用於iPhone的iOS模擬器(iOS4,XCode 3.2.3)
- 6. Xcode - 用於多種方法的宏
- 7. 適用於iPhone的JSON庫
- 8. 適用於iPhone的XML
- 9. 適用於iphone的FourSquare API
- 10. 適用於iPhone的Orkut API
- 11. 適用於iPhone的JSON庫
- 12. 適用於iPhone的iSpeech SDK
- 13. UIImageView.image適用於iPhone 5/ios7,但不適用於iPhone 4/ios 5
- 14. MKAnnotation setImage適用於iPhone,但不適用於iPad/iPhone 6+
- 15. XCode Allocations不適用於C?
- 16. genstrings不適用於NSLocalizedString的宏
- 17. 適用於Visual Studio的「新範圍」宏
- 18. Excel宏適用於PC,但不適用於Mac
- 19. 在視圖之間切換不適用於iPhone 5.1(XCode 4.3.2)
- 20. PJSIP TLS不適用於iPhone
- 21. cancelAllLocalNotifications;不適用於iPhone 3GS
- 22. imageWithContentsOfFile不適用於iPhone 5
- 23. @media不適用於iphone 5
- 24. dismissModelViewControllerAnimated不適用於iPhone 5
- 25. MMX指令適用於iphone
- 26. AVAudioPlayer不適用於iPhone 5
- 27. 想要列出適用於iOS(和Mac)的Xcode宏和預處理器符號
- 28. iPhone iAds不適用於iPhone 4
- 29. 適用於iPhone4的圖標/圖像(@ 2x)適用於iPhone 3GS?
- 30. 的Xcode 8 - 適用於建築x86_64的
請注意,我剛剛在腳本中添加了一個答案,該腳本一次執行屬性和綜合語句,並且還嘗試獲取屬性保留屬性正確(尚未將NSString vars標記爲「複製」)。 – 2010-02-03 00:11:47