├── Gemfile
├── Gemfile.lock
├── README.md
├── Rakefile
├── backup
├── 05D3F14F-45D6-44F5-B8C0-2A7337CD8269.codesnippet
├── 07A189DF-4995-4BD5-9B69-2D65D0CCE4B9.codesnippet
├── 119CDC92-44DD-4932-94F0-9A4B8BC8C374.codesnippet
├── 16700348-E9DD-4A2C-A31C-F448EAEB0EA0.codesnippet
├── 205997EB-E394-40F0-8C62-2355853051BA.codesnippet
├── 2368AC13-17E6-4B70-91CD-E0CF855838CB.codesnippet
├── 2D3CCD83-4654-4585-8B1E-85103FCFF706.codesnippet
├── 34BB15FB-7011-49C2-95D7-A730CDC30D08.codesnippet
├── 3D5741F9-0C90-47C9-A85D-BF29B48F1389.codesnippet
├── 43884B28-83A0-495A-A9C6-0DF21E803B66.codesnippet
├── 52731633-87D0-4ED9-B6A9-961D2AD3EA57.codesnippet
├── 59B5FBBE-3D36-47C5-90BC-0D463BD5AEF3.codesnippet
├── 5ED372EE-DF32-4580-A3A2-3617E7535513.codesnippet
├── 6059B091-689F-4539-AF72-220FA8D5AAAE.codesnippet
├── 6309B408-B532-40A7-8D86-F9A9A6CB9719.codesnippet
├── 701D6422-AA4F-4CD3-B7C4-F50033D2C0E6.codesnippet
├── 73CEF780-41F2-4431-9CF9-B25AA48784C1.codesnippet
├── 7AD1FC7E-F72D-4CE6-933D-98FAD6A8C721.codesnippet
├── 7C5D86F1-68BC-41B6-9C15-C5C0272D47AC.codesnippet
├── 88D4A8F6-CEF0-474B-B001-67BB58AEE270.codesnippet
├── 93D85AC5-F520-43B2-8914-9FE1867E6EDE.codesnippet
├── 976EF591-83CE-437D-8F73-F1705EC729BD.codesnippet
├── A50A9B42-6886-4A72-ADB9-80946A739CE8.codesnippet
├── B8953D95-6FA7-4059-A21D-09D26E91F74B.codesnippet
├── C1577379-4A1E-4E41-971D-C0CFA26487EB.codesnippet
├── C21E9F8E-BD69-4196-B9C1-1D35255DD1E6.codesnippet
├── DFE3B3EA-F43B-4EAF-9164-216F1693EFCA.codesnippet
├── E50D0BB6-37DF-4FD2-A8C7-87CD10FEAD30.codesnippet
├── E646849B-FAB2-454E-B16A-BDC978A0D6A7.codesnippet
├── EE946858-7D2A-4B72-A2A9-AAE18138BEF7.codesnippet
├── F17CDE7F-1CAA-4481-8C5A-F5CA531D1E3E.codesnippet
├── F7DE291D-D83A-4219-96A0-4E181AFFEB5C.codesnippet
├── F94645ED-50EC-4398-A8F9-67543B17AEE6.codesnippet
└── FB099D32-6D1A-4B78-896C-8F64BD2C7432.codesnippet
├── lib
├── Snippet.rb
├── readable-snippets-generator.rb
└── readme-generator.rb
└── readable_snippets
├── .m
├── Better_Initializer.m
├── Delegate_pragma_mark.m
├── Factory_method_with_Dictionary.m
├── Image_View_With_Image_Named.m
├── Image_named.m
├── Init_With_Dictionary.m
├── JSON_operation.m
├── Method_declaration.m
├── NSLog.m
├── NSString_with_format.m
├── Pragma_-_View_Lifecycle.m
├── Pragma_Mark.m
├── Private_Category.m
├── Private_Pragma_mark.m
├── Property_Custom_class.m
├── Property_From_dictionary.m
├── Property_IBOutlet_custom_class.m
├── Property_NSArray.m
├── Property_NSNumber.m
├── Property_String.m
├── Release_object.m
├── Singleton.m
├── Synthesizer_with__prefix.m
├── UITableView_delegate_and_datasource_default_methods.m
├── UIViewController_pragma_marks.m
├── Value_for_key.m
├── View_Did_Appear.m
├── View_Did_Load.m
├── View_Did_Unload.m
├── View_Will_Appear.m
├── View_Will_Dissappear.m
├── View_did_dissapear.m
└── Void_method_declaration.m
/Gemfile:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org'
2 |
3 | gem 'rake'
4 | gem 'nokogiri-plist'
5 |
--------------------------------------------------------------------------------
/Gemfile.lock:
--------------------------------------------------------------------------------
1 | GEM
2 | remote: https://rubygems.org/
3 | specs:
4 | nokogiri (1.5.0)
5 | nokogiri-plist (0.5.0)
6 | nokogiri
7 | rake (0.9.2.2)
8 |
9 | PLATFORMS
10 | ruby
11 |
12 | DEPENDENCIES
13 | nokogiri-plist
14 | rake
15 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Snippets backup-import & Cheatsheet generator
2 | #### For Xcode.
3 | You can __browse snippets__ from my xcode-arsenal in the __readable_snippets__ directory above.
4 |
5 | Below is the auto-generated cheat-sheet from your own exported snippets.
6 | It's created every time you back up your snippets and push to git.
7 |
8 | ### Installation
9 | Fork the repository, to be able to export your own snippets and cheat-sheet.
10 | You can save the repository wherever you want.
11 | `$ git clone https://github.com/mneorr/snippie.git xcode-snippets`
12 | `$ cd xcode-snippets`
13 | `$ bundle install`
14 |
15 | ### Standard usage
16 | ``$ rake backup``
17 | This will clear my snippets, and put yours in the repository.
18 |
19 | It will also generate readable snippets in the __readable_snippets__ dir.
20 | And, it will re-create this file.
21 |
22 | After you do backup, `commit` and `push`, and you should have your fork up and ready.
23 | The cheat-sheet will be updated as well.
24 |
25 | ### Import
26 | ##### to your other computers, or a new OS installation
27 | The simplest thing you can do is:
28 |
29 | `$ rake import`
30 |
31 | It should not duplicate the same snippets.
32 |
33 | However, if you want to clear the existing snippets, and use the fresh ones, you may want to use
34 | `$ rake clean_import`
35 |
36 |
37 |
38 | ## Cheat Sheet
39 |
40 | * Delegate pragma mark - `delpragma`
41 | * Image View With Image Named - `imgimg`
42 | * Release object - `release`
43 | * Property Custom class - `pobj`
44 | * Property From dictionary - `pvfk`
45 | * View did dissapear - `vdd`
46 | * View Will Dissappear - `vwd`
47 | * Pragma Mark - `mark`
48 | * Private Pragma mark - `pmark`
49 | * Better Initializer - `init`
50 | * View Will Appear - `vwa`
51 | * NSLog - `log`
52 | * Factory method with Dictionary - `facdict`
53 | * @Synthesizer with _prefix - `psynth`
54 | * Private Category - `privcat`
55 | * Pragma - View Lifecycle - `pview`
56 | * View Did Load - `vdl`
57 | * View Did Unload - `vdu`
58 | * - ``
59 | * View Did Appear - `vda`
60 | * NSString with format - `swf`
61 | * Property String - `pstr`
62 | * Init With Dictionary - `initdict`
63 | * Value For Key - `vfk`
64 | * Property NSNumber - `pnum`
65 | * UIViewController pragma marks - `conpragmas`
66 | * Singleton - `singleton`
67 | * Image named - `inamed`
68 | * Property IBOutlet custom class - `pibo`
69 | * UITableView delegate and datasource default methods - `delDat`
70 | * Property NSArray - `parr`
71 | * Method declaration - `method`
72 | * JSON operation - `jsonop`
73 | * Void method declaration - `void`
74 |
--------------------------------------------------------------------------------
/Rakefile:
--------------------------------------------------------------------------------
1 | require './lib/snippet'
2 | require './lib/readme-generator'
3 | require './lib/readable-snippets-generator'
4 | require 'fileutils'
5 |
6 | LIBRARY_SNIPPETS_DIR = "#{Dir.home}/Library/Developer/Xcode/UserData/CodeSnippets"
7 | SANDBOXED_SNIPPETS_DIR = "TODO: support for the App-Store downloaded Xcode snippets"
8 |
9 | BACKUP_DIR = 'backup'
10 |
11 | def initialize_snippets
12 | Dir.chdir BACKUP_DIR
13 | snippets = Dir['*.codesnippet'].map do |snippet_file|
14 | snippet = Snippet.parse(File.read(snippet_file))
15 | end
16 | Dir.chdir("../")
17 | return snippets
18 | end
19 |
20 | def raw_snippets
21 | @raw_snippets ||= initialize_snippets
22 | end
23 |
24 | def generate_readme
25 | ReadmeGenerator.generate raw_snippets
26 | end
27 |
28 | def backup_files
29 | FileUtils.rm_rf BACKUP_DIR
30 | FileUtils.cp_r LIBRARY_SNIPPETS_DIR, BACKUP_DIR
31 | # puts "#{Dir.entries(LIBRARY_SNIPPETS_DIR).count} snippets backed up."
32 | end
33 |
34 |
35 | def generate_readable_snippets
36 | FileUtils.rm_rf 'readable_snippets'
37 | FileUtils.mkdir 'readable_snippets'
38 |
39 | ReadableSnippetsGenerator.generate raw_snippets
40 | end
41 |
42 | def copy_snippets_to_xcode
43 | FileUtils.cp_r "#{BACKUP_DIR}/.", LIBRARY_SNIPPETS_DIR
44 | end
45 |
46 | task :backup do
47 | backup_files
48 | generate_readable_snippets
49 | generate_readme
50 |
51 | puts 'You have successfully backed up your snippets! Readable snippets are in ./readable_snippets folder.
52 | Commit / Push to see your new cheatsheet :)'
53 | end
54 |
55 | task :clean_import do
56 | FileUtils.cp_r "#{LIBRARY_SNIPPETS_DIR}/." , "#{Dir.home}/Desktop/OLD-snippets-backup"
57 | FileUtils.rm_rf "#{LIBRARY_SNIPPETS_DIR}/."
58 | copy_snippets_to_xcode
59 | end
60 |
61 | task :import do
62 | copy_snippets_to_xcode
63 | puts 'You have successfully imported your snippets in the Xcode.
64 | Please re-start Xcode to see the them :)'
65 | end
--------------------------------------------------------------------------------
/backup/05D3F14F-45D6-44F5-B8C0-2A7337CD8269.codesnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDECodeSnippetCompletionPrefix
6 | delpragma
7 | IDECodeSnippetCompletionScopes
8 |
9 | ClassImplementation
10 |
11 | IDECodeSnippetContents
12 | #pragma mark - <#delegate name#> delegate
13 |
14 |
15 | IDECodeSnippetIdentifier
16 | 05D3F14F-45D6-44F5-B8C0-2A7337CD8269
17 | IDECodeSnippetLanguage
18 | Xcode.SourceCodeLanguage.Objective-C
19 | IDECodeSnippetSummary
20 | Used for quickly inserting a pragma mark for custom delegates
21 | IDECodeSnippetTitle
22 | Delegate pragma mark
23 | IDECodeSnippetUserSnippet
24 |
25 | IDECodeSnippetVersion
26 | 2
27 |
28 |
29 |
--------------------------------------------------------------------------------
/backup/07A189DF-4995-4BD5-9B69-2D65D0CCE4B9.codesnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDECodeSnippetCompletionPrefix
6 | imgimg
7 | IDECodeSnippetCompletionScopes
8 |
9 | CodeBlock
10 |
11 | IDECodeSnippetContents
12 | [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"<# image #>"]]
13 | IDECodeSnippetIdentifier
14 | 07A189DF-4995-4BD5-9B69-2D65D0CCE4B9
15 | IDECodeSnippetLanguage
16 | Xcode.SourceCodeLanguage.Objective-C
17 | IDECodeSnippetSummary
18 | Gimme that image!
19 | IDECodeSnippetTitle
20 | Image View With Image Named
21 | IDECodeSnippetUserSnippet
22 |
23 | IDECodeSnippetVersion
24 | 2
25 |
26 |
27 |
--------------------------------------------------------------------------------
/backup/119CDC92-44DD-4932-94F0-9A4B8BC8C374.codesnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDECodeSnippetCompletionPrefix
6 | release
7 | IDECodeSnippetCompletionScopes
8 |
9 | CodeBlock
10 |
11 | IDECodeSnippetContents
12 | [<#object#> release];
13 | IDECodeSnippetIdentifier
14 | 119CDC92-44DD-4932-94F0-9A4B8BC8C374
15 | IDECodeSnippetLanguage
16 | Xcode.SourceCodeLanguage.Objective-C
17 | IDECodeSnippetSummary
18 | Used for releasing an object
19 | IDECodeSnippetTitle
20 | Release object
21 | IDECodeSnippetUserSnippet
22 |
23 | IDECodeSnippetVersion
24 | 2
25 |
26 |
27 |
--------------------------------------------------------------------------------
/backup/16700348-E9DD-4A2C-A31C-F448EAEB0EA0.codesnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDECodeSnippetCompletionPrefix
6 | pobj
7 | IDECodeSnippetCompletionScopes
8 |
9 | ClassInterfaceMethods
10 |
11 | IDECodeSnippetContents
12 | @property (strong, nonatomic) <#class#> *<#property#>;
13 | IDECodeSnippetIdentifier
14 | 16700348-E9DD-4A2C-A31C-F448EAEB0EA0
15 | IDECodeSnippetLanguage
16 | Xcode.SourceCodeLanguage.Objective-C
17 | IDECodeSnippetSummary
18 | Strong, Nonatomic property declaration
19 | IDECodeSnippetTitle
20 | Property Custom class
21 | IDECodeSnippetUserSnippet
22 |
23 | IDECodeSnippetVersion
24 | 2
25 |
26 |
27 |
--------------------------------------------------------------------------------
/backup/205997EB-E394-40F0-8C62-2355853051BA.codesnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDECodeSnippetCompletionPrefix
6 | pvfk
7 | IDECodeSnippetCompletionScopes
8 |
9 | CodeBlock
10 |
11 | IDECodeSnippetContents
12 | self.<#property#> = dictionary[@"<#key#>"];
13 | IDECodeSnippetIdentifier
14 | 205997EB-E394-40F0-8C62-2355853051BA
15 | IDECodeSnippetLanguage
16 | Xcode.SourceCodeLanguage.Objective-C
17 | IDECodeSnippetSummary
18 | Quickly set self.property with value for key
19 | IDECodeSnippetTitle
20 | Property From dictionary
21 | IDECodeSnippetUserSnippet
22 |
23 | IDECodeSnippetVersion
24 | 2
25 |
26 |
27 |
--------------------------------------------------------------------------------
/backup/2368AC13-17E6-4B70-91CD-E0CF855838CB.codesnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDECodeSnippetCompletionPrefix
6 | vdd
7 | IDECodeSnippetCompletionScopes
8 |
9 | ClassImplementation
10 |
11 | IDECodeSnippetContents
12 | -(void) viewDidDisappear:(BOOL)animated {
13 |
14 | [super viewDidDisappear:animated];
15 | }
16 | IDECodeSnippetIdentifier
17 | 2368AC13-17E6-4B70-91CD-E0CF855838CB
18 | IDECodeSnippetLanguage
19 | Xcode.SourceCodeLanguage.Objective-C
20 | IDECodeSnippetSummary
21 | Quick declaration
22 | IDECodeSnippetTitle
23 | View did dissapear
24 | IDECodeSnippetUserSnippet
25 |
26 | IDECodeSnippetVersion
27 | 2
28 |
29 |
30 |
--------------------------------------------------------------------------------
/backup/2D3CCD83-4654-4585-8B1E-85103FCFF706.codesnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDECodeSnippetCompletionPrefix
6 | vwd
7 | IDECodeSnippetCompletionScopes
8 |
9 | ClassImplementation
10 |
11 | IDECodeSnippetContents
12 | - (void)viewWillDisappear:(BOOL)animated {
13 | <# code #>
14 |
15 | [super viewWillDisappear:animated];
16 | }
17 | IDECodeSnippetIdentifier
18 | 2D3CCD83-4654-4585-8B1E-85103FCFF706
19 | IDECodeSnippetLanguage
20 | Xcode.SourceCodeLanguage.Objective-C
21 | IDECodeSnippetSummary
22 | quickly define method
23 | IDECodeSnippetTitle
24 | View Will Dissappear
25 | IDECodeSnippetUserSnippet
26 |
27 | IDECodeSnippetVersion
28 | 2
29 |
30 |
31 |
--------------------------------------------------------------------------------
/backup/34BB15FB-7011-49C2-95D7-A730CDC30D08.codesnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDECodeSnippetCompletionPrefix
6 | mark
7 | IDECodeSnippetCompletionScopes
8 |
9 | ClassImplementation
10 |
11 | IDECodeSnippetContents
12 | #pragma mark - <#pragma name#>
13 |
14 |
15 | IDECodeSnippetIdentifier
16 | 34BB15FB-7011-49C2-95D7-A730CDC30D08
17 | IDECodeSnippetLanguage
18 | Xcode.SourceCodeLanguage.Objective-C
19 | IDECodeSnippetSummary
20 | Quicker way to add a pragma mark
21 | IDECodeSnippetTitle
22 | Pragma Mark
23 | IDECodeSnippetUserSnippet
24 |
25 | IDECodeSnippetVersion
26 | 2
27 |
28 |
29 |
--------------------------------------------------------------------------------
/backup/3D5741F9-0C90-47C9-A85D-BF29B48F1389.codesnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDECodeSnippetCompletionPrefix
6 | pmark
7 | IDECodeSnippetCompletionScopes
8 |
9 | ClassImplementation
10 |
11 | IDECodeSnippetContents
12 | #pragma mark - Private
13 | IDECodeSnippetIdentifier
14 | 3D5741F9-0C90-47C9-A85D-BF29B48F1389
15 | IDECodeSnippetLanguage
16 | Xcode.SourceCodeLanguage.Objective-C
17 | IDECodeSnippetSummary
18 | #pragma mark - Private
19 | IDECodeSnippetTitle
20 | Private Pragma mark
21 | IDECodeSnippetUserSnippet
22 |
23 | IDECodeSnippetVersion
24 | 2
25 |
26 |
27 |
--------------------------------------------------------------------------------
/backup/43884B28-83A0-495A-A9C6-0DF21E803B66.codesnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDECodeSnippetCompletionPrefix
6 | init
7 | IDECodeSnippetCompletionScopes
8 |
9 | ClassImplementation
10 |
11 | IDECodeSnippetContents
12 | - (id)init {
13 | self = [super init];
14 | if (!self) return nil;
15 |
16 | <#initializations#>
17 |
18 | return self;
19 | }
20 | IDECodeSnippetIdentifier
21 | 43884B28-83A0-495A-A9C6-0DF21E803B66
22 | IDECodeSnippetLanguage
23 | Xcode.SourceCodeLanguage.Objective-C
24 | IDECodeSnippetSummary
25 | Used for generating an -(id)init mehod
26 | IDECodeSnippetTitle
27 | Better Initializer
28 | IDECodeSnippetUserSnippet
29 |
30 | IDECodeSnippetVersion
31 | 2
32 |
33 |
34 |
--------------------------------------------------------------------------------
/backup/52731633-87D0-4ED9-B6A9-961D2AD3EA57.codesnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDECodeSnippetCompletionPrefix
6 | vwa
7 | IDECodeSnippetCompletionScopes
8 |
9 | ClassImplementation
10 |
11 | IDECodeSnippetContents
12 | - (void)viewWillAppear:(BOOL)animated {
13 | [super viewWillAppear:animated];
14 |
15 | <# code #>
16 | }
17 | IDECodeSnippetIdentifier
18 | 52731633-87D0-4ED9-B6A9-961D2AD3EA57
19 | IDECodeSnippetLanguage
20 | Xcode.SourceCodeLanguage.Objective-C
21 | IDECodeSnippetSummary
22 | quickly define method
23 | IDECodeSnippetTitle
24 | View Will Appear
25 | IDECodeSnippetUserSnippet
26 |
27 | IDECodeSnippetVersion
28 | 2
29 |
30 |
31 |
--------------------------------------------------------------------------------
/backup/59B5FBBE-3D36-47C5-90BC-0D463BD5AEF3.codesnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDECodeSnippetCompletionPrefix
6 | log
7 | IDECodeSnippetCompletionScopes
8 |
9 | CodeBlock
10 |
11 | IDECodeSnippetContents
12 | NSLog(@"<# your text here #> %@", <#variables here#>);
13 | IDECodeSnippetIdentifier
14 | 59B5FBBE-3D36-47C5-90BC-0D463BD5AEF3
15 | IDECodeSnippetLanguage
16 | Xcode.SourceCodeLanguage.Objective-C
17 | IDECodeSnippetSummary
18 | A Quicker way to log out the stuff
19 | IDECodeSnippetTitle
20 | NSLog
21 | IDECodeSnippetUserSnippet
22 |
23 | IDECodeSnippetVersion
24 | 2
25 |
26 |
27 |
--------------------------------------------------------------------------------
/backup/5ED372EE-DF32-4580-A3A2-3617E7535513.codesnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDECodeSnippetCompletionPrefix
6 | facdict
7 | IDECodeSnippetCompletionScopes
8 |
9 | CodeBlock
10 |
11 | IDECodeSnippetContents
12 | NSMutableArray *renameMe = [NSMutableArray new];
13 |
14 | for (NSDictionary *renameDict in json[@"<#key#>"])
15 | [renameMe addObject:[[<#klass#> alloc] initWithDictionary:renameDict]];
16 |
17 | return renameMe;
18 | IDECodeSnippetIdentifier
19 | 5ED372EE-DF32-4580-A3A2-3617E7535513
20 | IDECodeSnippetLanguage
21 | Xcode.SourceCodeLanguage.Objective-C
22 | IDECodeSnippetSummary
23 | For loop with a Mutable Array
24 | IDECodeSnippetTitle
25 | Factory method with Dictionary
26 | IDECodeSnippetUserSnippet
27 |
28 | IDECodeSnippetVersion
29 | 2
30 |
31 |
32 |
--------------------------------------------------------------------------------
/backup/6059B091-689F-4539-AF72-220FA8D5AAAE.codesnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDECodeSnippetCompletionPrefix
6 | psynth
7 | IDECodeSnippetCompletionScopes
8 |
9 | ClassImplementation
10 |
11 | IDECodeSnippetContents
12 | @synthesize <#property#> = _<#property#>;
13 | IDECodeSnippetIdentifier
14 | 6059B091-689F-4539-AF72-220FA8D5AAAE
15 | IDECodeSnippetLanguage
16 | Xcode.SourceCodeLanguage.Objective-C
17 | IDECodeSnippetSummary
18 | Synthesize with property=_property
19 | IDECodeSnippetTitle
20 | @Synthesizer with _prefix
21 | IDECodeSnippetUserSnippet
22 |
23 | IDECodeSnippetVersion
24 | 2
25 |
26 |
27 |
--------------------------------------------------------------------------------
/backup/6309B408-B532-40A7-8D86-F9A9A6CB9719.codesnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDECodeSnippetCompletionPrefix
6 | privcat
7 | IDECodeSnippetCompletionScopes
8 |
9 | TopLevel
10 |
11 | IDECodeSnippetContents
12 | @interface <#Class Name#> ()
13 | - (<#type#>)<#method name#>;
14 | @end
15 | IDECodeSnippetIdentifier
16 | 6309B408-B532-40A7-8D86-F9A9A6CB9719
17 | IDECodeSnippetLanguage
18 | Xcode.SourceCodeLanguage.Objective-C
19 | IDECodeSnippetSummary
20 | Used for declaring private methods
21 | IDECodeSnippetTitle
22 | Private Category
23 | IDECodeSnippetUserSnippet
24 |
25 | IDECodeSnippetVersion
26 | 2
27 |
28 |
29 |
--------------------------------------------------------------------------------
/backup/701D6422-AA4F-4CD3-B7C4-F50033D2C0E6.codesnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDECodeSnippetCompletionPrefix
6 | pview
7 | IDECodeSnippetCompletionScopes
8 |
9 | ClassImplementation
10 |
11 | IDECodeSnippetContents
12 | #pragma mark - View Lifecycle
13 | IDECodeSnippetIdentifier
14 | 701D6422-AA4F-4CD3-B7C4-F50033D2C0E6
15 | IDECodeSnippetLanguage
16 | Xcode.SourceCodeLanguage.Objective-C
17 | IDECodeSnippetSummary
18 | Pragma mark for View Lifecycle
19 | IDECodeSnippetTitle
20 | Pragma - View Lifecycle
21 | IDECodeSnippetUserSnippet
22 |
23 | IDECodeSnippetVersion
24 | 2
25 |
26 |
27 |
--------------------------------------------------------------------------------
/backup/73CEF780-41F2-4431-9CF9-B25AA48784C1.codesnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDECodeSnippetCompletionPrefix
6 | vdl
7 | IDECodeSnippetCompletionScopes
8 |
9 | ClassImplementation
10 |
11 | IDECodeSnippetContents
12 | - (void)viewDidLoad {
13 | [super viewDidLoad];
14 | <#code#>
15 | }
16 |
17 | IDECodeSnippetIdentifier
18 | 73CEF780-41F2-4431-9CF9-B25AA48784C1
19 | IDECodeSnippetLanguage
20 | Xcode.SourceCodeLanguage.Objective-C
21 | IDECodeSnippetSummary
22 | Quickly type view did load snippet
23 | IDECodeSnippetTitle
24 | View Did Load
25 | IDECodeSnippetUserSnippet
26 |
27 | IDECodeSnippetVersion
28 | 2
29 |
30 |
31 |
--------------------------------------------------------------------------------
/backup/7AD1FC7E-F72D-4CE6-933D-98FAD6A8C721.codesnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDECodeSnippetCompletionPrefix
6 | vdu
7 | IDECodeSnippetCompletionScopes
8 |
9 | ClassImplementation
10 |
11 | IDECodeSnippetContents
12 | - (void)viewDidUnload {
13 | [super viewDidUnload];
14 | <#code#>
15 | }
16 |
17 | IDECodeSnippetIdentifier
18 | 7AD1FC7E-F72D-4CE6-933D-98FAD6A8C721
19 | IDECodeSnippetLanguage
20 | Xcode.SourceCodeLanguage.Objective-C
21 | IDECodeSnippetSummary
22 | Quick ViewDidUnload declaration
23 | IDECodeSnippetTitle
24 | View Did Unload
25 | IDECodeSnippetUserSnippet
26 |
27 | IDECodeSnippetVersion
28 | 2
29 |
30 |
31 |
--------------------------------------------------------------------------------
/backup/7C5D86F1-68BC-41B6-9C15-C5C0272D47AC.codesnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDECodeSnippetCompletionScopes
6 |
7 | CodeExpression
8 |
9 | IDECodeSnippetContents
10 |
11 | IDECodeSnippetIdentifier
12 | 7C5D86F1-68BC-41B6-9C15-C5C0272D47AC
13 | IDECodeSnippetLanguage
14 | Xcode.SourceCodeLanguage.Objective-C
15 | IDECodeSnippetTitle
16 |
17 | IDECodeSnippetUserSnippet
18 |
19 | IDECodeSnippetVersion
20 | 2
21 |
22 |
23 |
--------------------------------------------------------------------------------
/backup/88D4A8F6-CEF0-474B-B001-67BB58AEE270.codesnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDECodeSnippetCompletionPrefix
6 | vda
7 | IDECodeSnippetCompletionScopes
8 |
9 | ClassImplementation
10 |
11 | IDECodeSnippetContents
12 | - (void)viewDidAppear:(BOOL)animated {
13 | [super viewDidAppear:animated];
14 |
15 | }
16 | IDECodeSnippetIdentifier
17 | 88D4A8F6-CEF0-474B-B001-67BB58AEE270
18 | IDECodeSnippetLanguage
19 | Xcode.SourceCodeLanguage.Objective-C
20 | IDECodeSnippetSummary
21 | Quickly insert that piece of code!
22 | IDECodeSnippetTitle
23 | View Did Appear
24 | IDECodeSnippetUserSnippet
25 |
26 | IDECodeSnippetVersion
27 | 2
28 |
29 |
30 |
--------------------------------------------------------------------------------
/backup/93D85AC5-F520-43B2-8914-9FE1867E6EDE.codesnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDECodeSnippetCompletionPrefix
6 | swf
7 | IDECodeSnippetCompletionScopes
8 |
9 | CodeExpression
10 |
11 | IDECodeSnippetContents
12 | [NSString stringWithFormat:@"<#your string and %@'s here#>", <#arguments#>]
13 | IDECodeSnippetIdentifier
14 | 93D85AC5-F520-43B2-8914-9FE1867E6EDE
15 | IDECodeSnippetLanguage
16 | Xcode.SourceCodeLanguage.Objective-C
17 | IDECodeSnippetSummary
18 | Quicker way to do NSString with format
19 | IDECodeSnippetTitle
20 | NSString with format
21 | IDECodeSnippetUserSnippet
22 |
23 | IDECodeSnippetVersion
24 | 2
25 |
26 |
27 |
--------------------------------------------------------------------------------
/backup/976EF591-83CE-437D-8F73-F1705EC729BD.codesnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDECodeSnippetCompletionPrefix
6 | pstr
7 | IDECodeSnippetCompletionScopes
8 |
9 | ClassInterfaceMethods
10 |
11 | IDECodeSnippetContents
12 | @property (strong, nonatomic) NSString *<#property#>;
13 | IDECodeSnippetIdentifier
14 | 976EF591-83CE-437D-8F73-F1705EC729BD
15 | IDECodeSnippetLanguage
16 | Xcode.SourceCodeLanguage.Objective-C
17 | IDECodeSnippetSummary
18 | Strong, nonatomic string property declaration
19 | IDECodeSnippetTitle
20 | Property String
21 | IDECodeSnippetUserSnippet
22 |
23 | IDECodeSnippetVersion
24 | 2
25 |
26 |
27 |
--------------------------------------------------------------------------------
/backup/A50A9B42-6886-4A72-ADB9-80946A739CE8.codesnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDECodeSnippetCompletionPrefix
6 | initdict
7 | IDECodeSnippetCompletionScopes
8 |
9 | ClassImplementation
10 |
11 | IDECodeSnippetContents
12 | - (id)initWithDictionary:(NSDictionary *)dict {
13 | self = [super init];
14 | if (!self) return nil;
15 |
16 | [self unpackFromDictionary:dict];
17 |
18 | return self;
19 | }
20 |
21 | - (NSDictionary *)toDictionary {
22 | NSMutableDictionary *dict = [NSMutableDictionary new];
23 |
24 | return dict;
25 | }
26 |
27 | #pragma mark - Private
28 |
29 | - (void)unpackFromDictionary:(NSDictionary *)dictionary {
30 |
31 | }
32 | IDECodeSnippetIdentifier
33 | A50A9B42-6886-4A72-ADB9-80946A739CE8
34 | IDECodeSnippetLanguage
35 | Xcode.SourceCodeLanguage.Objective-C
36 | IDECodeSnippetSummary
37 | Initializer and Unpack method
38 | IDECodeSnippetTitle
39 | Init With Dictionary
40 | IDECodeSnippetUserSnippet
41 |
42 | IDECodeSnippetVersion
43 | 2
44 |
45 |
46 |
--------------------------------------------------------------------------------
/backup/B8953D95-6FA7-4059-A21D-09D26E91F74B.codesnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDECodeSnippetCompletionPrefix
6 | vfk
7 | IDECodeSnippetCompletionScopes
8 |
9 | CodeExpression
10 |
11 | IDECodeSnippetContents
12 | <#dictionary#>[@"<#the key#>"]
13 | IDECodeSnippetIdentifier
14 | B8953D95-6FA7-4059-A21D-09D26E91F74B
15 | IDECodeSnippetLanguage
16 | Xcode.SourceCodeLanguage.Objective-C
17 | IDECodeSnippetSummary
18 | Modern OBJC syntax for getting a value from dict
19 | IDECodeSnippetTitle
20 | Value For Key
21 | IDECodeSnippetUserSnippet
22 |
23 | IDECodeSnippetVersion
24 | 2
25 |
26 |
27 |
--------------------------------------------------------------------------------
/backup/C1577379-4A1E-4E41-971D-C0CFA26487EB.codesnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDECodeSnippetCompletionPrefix
6 | pnum
7 | IDECodeSnippetCompletionScopes
8 |
9 | ClassInterfaceMethods
10 |
11 | IDECodeSnippetContents
12 | @property (strong, nonatomic) NSNumber *<#property#>;
13 | IDECodeSnippetIdentifier
14 | C1577379-4A1E-4E41-971D-C0CFA26487EB
15 | IDECodeSnippetLanguage
16 | Xcode.SourceCodeLanguage.Objective-C-Plus-Plus
17 | IDECodeSnippetSummary
18 | Strong, Nonatomic NSNumber property declaration
19 | IDECodeSnippetTitle
20 | Property NSNumber
21 | IDECodeSnippetUserSnippet
22 |
23 | IDECodeSnippetVersion
24 | 2
25 |
26 |
27 |
--------------------------------------------------------------------------------
/backup/C21E9F8E-BD69-4196-B9C1-1D35255DD1E6.codesnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDECodeSnippetCompletionPrefix
6 | conpragmas
7 | IDECodeSnippetCompletionScopes
8 |
9 | ClassImplementation
10 |
11 | IDECodeSnippetContents
12 | #pragma mark - Private
13 |
14 |
15 |
16 | #pragma mark - View lifecycle
17 |
18 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
19 | return (interfaceOrientation == UIInterfaceOrientationPortrait);
20 | }
21 |
22 |
23 | #pragma mark - Public
24 |
25 |
26 | #pragma mark - IBActions
27 | IDECodeSnippetIdentifier
28 | C21E9F8E-BD69-4196-B9C1-1D35255DD1E6
29 | IDECodeSnippetLanguage
30 | Xcode.SourceCodeLanguage.Objective-C
31 | IDECodeSnippetSummary
32 | Pragma marks for the better code organisation. Private on the top eliminates the need of declaring a private interface.
33 | IDECodeSnippetTitle
34 | UIViewController pragma marks
35 | IDECodeSnippetUserSnippet
36 |
37 | IDECodeSnippetVersion
38 | 2
39 |
40 |
41 |
--------------------------------------------------------------------------------
/backup/DFE3B3EA-F43B-4EAF-9164-216F1693EFCA.codesnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDECodeSnippetCompletionPrefix
6 | singleton
7 | IDECodeSnippetCompletionScopes
8 |
9 | ClassImplementation
10 |
11 | IDECodeSnippetContents
12 | #pragma mark - Singleton
13 | static <#self class#> *singleton;
14 |
15 | + (instancetype)instance {
16 | static dispatch_once_t singletonToken;
17 | dispatch_once(&singletonToken, ^{
18 | singleton = [[self alloc] init];
19 | });
20 |
21 | return singleton;
22 | }
23 | IDECodeSnippetIdentifier
24 | DFE3B3EA-F43B-4EAF-9164-216F1693EFCA
25 | IDECodeSnippetLanguage
26 | Xcode.SourceCodeLanguage.Objective-C
27 | IDECodeSnippetSummary
28 | Quickly declare a singleton
29 | IDECodeSnippetTitle
30 | Singleton
31 | IDECodeSnippetUserSnippet
32 |
33 | IDECodeSnippetVersion
34 | 2
35 |
36 |
37 |
--------------------------------------------------------------------------------
/backup/E50D0BB6-37DF-4FD2-A8C7-87CD10FEAD30.codesnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDECodeSnippetCompletionPrefix
6 | inamed
7 | IDECodeSnippetCompletionScopes
8 |
9 | CodeExpression
10 |
11 | IDECodeSnippetContents
12 | [UIImage imageNamed:@"<#name#>"]
13 | IDECodeSnippetIdentifier
14 | E50D0BB6-37DF-4FD2-A8C7-87CD10FEAD30
15 | IDECodeSnippetLanguage
16 | Xcode.SourceCodeLanguage.Objective-C
17 | IDECodeSnippetSummary
18 | Quick way for [UIImage imageNamed:@""]
19 | IDECodeSnippetTitle
20 | Image named
21 | IDECodeSnippetUserSnippet
22 |
23 | IDECodeSnippetVersion
24 | 2
25 |
26 |
27 |
--------------------------------------------------------------------------------
/backup/E646849B-FAB2-454E-B16A-BDC978A0D6A7.codesnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDECodeSnippetCompletionPrefix
6 | pibo
7 | IDECodeSnippetCompletionScopes
8 |
9 | ClassInterfaceMethods
10 |
11 | IDECodeSnippetContents
12 | @property (strong, nonatomic) IBOutlet <#klass#> *<#property#>;
13 | IDECodeSnippetIdentifier
14 | E646849B-FAB2-454E-B16A-BDC978A0D6A7
15 | IDECodeSnippetLanguage
16 | Xcode.SourceCodeLanguage.Objective-C
17 | IDECodeSnippetSummary
18 | Strong, Nonatomic IBOutlet property declaration
19 | IDECodeSnippetTitle
20 | Property IBOutlet custom class
21 | IDECodeSnippetUserSnippet
22 |
23 | IDECodeSnippetVersion
24 | 2
25 |
26 |
27 |
--------------------------------------------------------------------------------
/backup/EE946858-7D2A-4B72-A2A9-AAE18138BEF7.codesnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDECodeSnippetCompletionPrefix
6 | delDat
7 | IDECodeSnippetCompletionScopes
8 |
9 | ClassImplementation
10 |
11 | IDECodeSnippetContents
12 | #pragma mark - Tableview datasource
13 |
14 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
15 | static NSString *CellIdentifier = @"Cell";
16 |
17 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
18 | cell.<# property #> = <# model #>;
19 | return cell;
20 | }
21 |
22 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
23 | return <#numberOfSections#>;
24 | }
25 |
26 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
27 | return <#numberOfRows#>;
28 | }
29 |
30 |
31 | #pragma mark - Tableview delegate
32 |
33 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {}
34 |
35 | IDECodeSnippetIdentifier
36 | EE946858-7D2A-4B72-A2A9-AAE18138BEF7
37 | IDECodeSnippetLanguage
38 | Xcode.SourceCodeLanguage.Objective-C
39 | IDECodeSnippetSummary
40 | Used when adding an tableView in existing controller
41 | IDECodeSnippetTitle
42 | UITableView delegate and datasource default methods
43 | IDECodeSnippetUserSnippet
44 |
45 | IDECodeSnippetVersion
46 | 2
47 |
48 |
49 |
--------------------------------------------------------------------------------
/backup/F17CDE7F-1CAA-4481-8C5A-F5CA531D1E3E.codesnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDECodeSnippetCompletionPrefix
6 | parr
7 | IDECodeSnippetCompletionScopes
8 |
9 | ClassInterfaceMethods
10 |
11 | IDECodeSnippetContents
12 | @property (strong, nonatomic) NSArray *<#property#>;
13 | IDECodeSnippetIdentifier
14 | F17CDE7F-1CAA-4481-8C5A-F5CA531D1E3E
15 | IDECodeSnippetLanguage
16 | Xcode.SourceCodeLanguage.Objective-C
17 | IDECodeSnippetSummary
18 | Strong, Nonatomic NSArray property declaration
19 | IDECodeSnippetTitle
20 | Property NSArray
21 | IDECodeSnippetUserSnippet
22 |
23 | IDECodeSnippetVersion
24 | 2
25 |
26 |
27 |
--------------------------------------------------------------------------------
/backup/F7DE291D-D83A-4219-96A0-4E181AFFEB5C.codesnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDECodeSnippetCompletionPrefix
6 | method
7 | IDECodeSnippetCompletionScopes
8 |
9 | ClassImplementation
10 |
11 | IDECodeSnippetContents
12 | - (<#class#> *)<#metod name#>
13 | IDECodeSnippetIdentifier
14 | F7DE291D-D83A-4219-96A0-4E181AFFEB5C
15 | IDECodeSnippetLanguage
16 | Xcode.SourceCodeLanguage.Objective-C
17 | IDECodeSnippetSummary
18 | Quicker way to declare a method
19 | IDECodeSnippetTitle
20 | Method declaration
21 | IDECodeSnippetUserSnippet
22 |
23 | IDECodeSnippetVersion
24 | 2
25 |
26 |
27 |
--------------------------------------------------------------------------------
/backup/F94645ED-50EC-4398-A8F9-67543B17AEE6.codesnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDECodeSnippetCompletionPrefix
6 | jsonop
7 | IDECodeSnippetCompletionScopes
8 |
9 | CodeBlock
10 |
11 | IDECodeSnippetContents
12 | [[AFJSONRequestOperation JSONRequestOperationWithRequest:nil
13 | success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
14 |
15 | }
16 | failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {
17 |
18 | }] start];
19 |
20 | IDECodeSnippetIdentifier
21 | F94645ED-50EC-4398-A8F9-67543B17AEE6
22 | IDECodeSnippetLanguage
23 | Xcode.SourceCodeLanguage.Objective-C
24 | IDECodeSnippetSummary
25 | AFNetworking JSON operation
26 | IDECodeSnippetTitle
27 | JSON operation
28 | IDECodeSnippetUserSnippet
29 |
30 | IDECodeSnippetVersion
31 | 2
32 |
33 |
34 |
--------------------------------------------------------------------------------
/backup/FB099D32-6D1A-4B78-896C-8F64BD2C7432.codesnippet:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDECodeSnippetCompletionPrefix
6 | void
7 | IDECodeSnippetCompletionScopes
8 |
9 | ClassInterfaceMethods
10 | ClassImplementation
11 |
12 | IDECodeSnippetContents
13 | - (void)<#metod name#>
14 | IDECodeSnippetIdentifier
15 | FB099D32-6D1A-4B78-896C-8F64BD2C7432
16 | IDECodeSnippetLanguage
17 | Xcode.SourceCodeLanguage.Objective-C
18 | IDECodeSnippetSummary
19 | Quickly declare a void method
20 | IDECodeSnippetTitle
21 | Void method declaration
22 | IDECodeSnippetUserSnippet
23 |
24 | IDECodeSnippetVersion
25 | 2
26 |
27 |
28 |
--------------------------------------------------------------------------------
/lib/Snippet.rb:
--------------------------------------------------------------------------------
1 | #Credits to burtlo/xcode-snippets for this great implementation
2 |
3 | require 'nokogiri-plist'
4 |
5 | class Snippet
6 |
7 | def self.parse(snippet_filedata)
8 | self.new Nokogiri::PList(snippet_filedata)
9 | end
10 |
11 | def initialize(properties = {})
12 | @properties = properties
13 | end
14 |
15 | def value_for_key(key)
16 | @properties[key]
17 | end
18 |
19 | def shortcut
20 | value_for_key "IDECodeSnippetCompletionPrefix"
21 | end
22 |
23 | def code
24 | value_for_key "IDECodeSnippetContents"
25 | end
26 |
27 | def title
28 | value_for_key "IDECodeSnippetTitle"
29 | end
30 |
31 | def summary
32 | value_for_key "IDECodeSnippetSummary"
33 | end
34 |
35 | def completion_scopes
36 | value_for_key "IDECodeSnippetCompletionScopes"
37 | end
38 |
39 | def language
40 | (value_for_key "IDECodeSnippetLanguage").gsub "Xcode.SourceCodeLanguage.", ""
41 | end
42 |
43 | end
--------------------------------------------------------------------------------
/lib/readable-snippets-generator.rb:
--------------------------------------------------------------------------------
1 | class ReadableSnippetsGenerator
2 |
3 | def initialize(snippets)
4 | @snippets = snippets
5 | end
6 |
7 | def self.generate(snippets)
8 | Dir.chdir('readable_snippets')
9 |
10 | self.new(snippets).save_files
11 |
12 | Dir.chdir('../')
13 | end
14 |
15 | def formatted_snippets
16 | @snippets.map do |snippet|
17 | {
18 | :filename => friendly_filename(snippet.title),
19 | :ext => ext(snippet.language),
20 | :content => [
21 | "//#{snippet.title}\n" <<
22 | "//#{snippet.summary}\n" <<
23 | "//\n" <<
24 | "//Completion scopes: #{ snippet.completion_scopes}\n" <<
25 | "//Language: #{ snippet.language }\n" <<
26 | "//\n" <<
27 | "Copy / Paste in Xcode:\n\n" <<
28 | "#{snippet.code}"
29 | ]
30 | }
31 | end
32 | end
33 |
34 | def save_snippet(formatted_snippet)
35 | File.open "#{formatted_snippet[:filename]}.#{formatted_snippet[:ext]}", 'w' do |file|
36 | file.puts formatted_snippet[:content]
37 | end
38 | end
39 |
40 | def save_files
41 | formatted_snippets.each do |snippet|
42 | save_snippet(snippet)
43 | end
44 | end
45 |
46 | def friendly_filename(filename)
47 | filename.gsub(/[^\w\s_-]+/, '')
48 | .gsub(/(^|\b\s)\s+($|\s?\b)/, '\\1\\2')
49 | .gsub(/\s/, '_')
50 | end
51 |
52 | def ext(language)
53 | if language == 'Swift'
54 | return 'swift'
55 | else
56 | return 'm'
57 | end
58 | end
59 | end
--------------------------------------------------------------------------------
/lib/readme-generator.rb:
--------------------------------------------------------------------------------
1 | require 'fileutils'
2 |
3 | class ReadmeGenerator
4 |
5 | def initialize(snippets)
6 | @README_FILENAME = 'README.md'
7 | @snippets = snippets
8 | end
9 |
10 | def self.generate(snippets)
11 | generator = self.new(snippets)
12 | generator.delete_old_readme
13 | generator.create_readme
14 | end
15 |
16 | def formatted_snippets
17 | @snippets.sort_by!(&:title).map do |snippet|
18 | [ "* #{snippet.title} - `#{snippet.shortcut}`" ]
19 | end
20 | end
21 |
22 | def create_readme
23 | File.open @README_FILENAME, 'w' do |file|
24 | file.puts readme_title
25 | file.puts formatted_snippets.join("\n")
26 | end
27 | end
28 |
29 | def delete_old_readme
30 | FileUtils.rm_f @README_FILENAME
31 | end
32 |
33 | def readme_title
34 | %{# Snippets backup-import & Cheatsheet generator
35 | #### For Xcode.
36 | You can __browse snippets__ from my xcode-arsenal in the __readable_snippets__ directory above.
37 |
38 | Below is the auto-generated cheat-sheet from your own exported snippets.
39 | It's created every time you back up your snippets and push to git.
40 |
41 | ### Installation
42 | Fork the repository, to be able to export your own snippets and cheat-sheet.
43 | You can save the repository wherever you want.
44 | `$ git clone git@github.com:mneorr/xcode-snippets-manager.git xcode-snippets`
45 | `$ cd xcode-snippets`
46 | `$ bundle install`
47 |
48 | ### Standard usage
49 | ``$ rake backup``
50 | This will clear my snippets, and put yours in the repository.
51 |
52 | It will also generate readable snippets in the __readable_snippets__ dir.
53 | And, it will re-create this file.
54 |
55 | After you do backup, `commit` and `push`, and you should have your fork up and ready.
56 | The cheat-sheet will be updated as well.
57 |
58 | ### Import
59 | ##### to your other computers, or a new OS installation
60 | The simplest thing you can do is:
61 |
62 | `$ rake import`
63 |
64 | It should not duplicate the same snippets.
65 |
66 | However, if you want to clear the existing snippets, and use the fresh ones, you may want to use
67 | `$ rake clean_import`
68 |
69 |
70 |
71 | ## Cheat Sheet
72 | }
73 |
74 | end
75 |
76 | end
77 |
--------------------------------------------------------------------------------
/readable_snippets/.m:
--------------------------------------------------------------------------------
1 | //
2 | //
3 | //
4 | //Completion scopes: ["CodeExpression"]
5 | //
6 | Copy / Paste in Xcode:
7 |
8 |
--------------------------------------------------------------------------------
/readable_snippets/Better_Initializer.m:
--------------------------------------------------------------------------------
1 | //Better Initializer
2 | //Used for generating an -(id)init mehod
3 | //
4 | //Completion scopes: ["ClassImplementation"]
5 | //
6 | Copy / Paste in Xcode:
7 |
8 | - (id)init {
9 | self = [super init];
10 | if (!self) return nil;
11 |
12 | <#initializations#>
13 |
14 | return self;
15 | }
16 |
--------------------------------------------------------------------------------
/readable_snippets/Delegate_pragma_mark.m:
--------------------------------------------------------------------------------
1 | //Delegate pragma mark
2 | //Used for quickly inserting a pragma mark for custom delegates
3 | //
4 | //Completion scopes: ["ClassImplementation"]
5 | //
6 | Copy / Paste in Xcode:
7 |
8 | #pragma mark - <#delegate name#> delegate
9 |
10 |
--------------------------------------------------------------------------------
/readable_snippets/Factory_method_with_Dictionary.m:
--------------------------------------------------------------------------------
1 | //Factory method with Dictionary
2 | //For loop with a Mutable Array
3 | //
4 | //Completion scopes: ["CodeBlock"]
5 | //
6 | Copy / Paste in Xcode:
7 |
8 | NSMutableArray *renameMe = [NSMutableArray new];
9 |
10 | for (NSDictionary *renameDict in json[@"<#key#>"])
11 | [renameMe addObject:[[<#klass#> alloc] initWithDictionary:renameDict]];
12 |
13 | return renameMe;
14 |
--------------------------------------------------------------------------------
/readable_snippets/Image_View_With_Image_Named.m:
--------------------------------------------------------------------------------
1 | //Image View With Image Named
2 | //Gimme that image!
3 | //
4 | //Completion scopes: ["CodeBlock"]
5 | //
6 | Copy / Paste in Xcode:
7 |
8 | [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"<# image #>"]]
9 |
--------------------------------------------------------------------------------
/readable_snippets/Image_named.m:
--------------------------------------------------------------------------------
1 | //Image named
2 | //Quick way for [UIImage imageNamed:@""]
3 | //
4 | //Completion scopes: ["CodeExpression"]
5 | //
6 | Copy / Paste in Xcode:
7 |
8 | [UIImage imageNamed:@"<#name#>"]
9 |
--------------------------------------------------------------------------------
/readable_snippets/Init_With_Dictionary.m:
--------------------------------------------------------------------------------
1 | //Init With Dictionary
2 | //Initializer and Unpack method
3 | //
4 | //Completion scopes: ["ClassImplementation"]
5 | //
6 | Copy / Paste in Xcode:
7 |
8 | - (id)initWithDictionary:(NSDictionary *)dict {
9 | self = [super init];
10 | if (!self) return nil;
11 |
12 | [self unpackFromDictionary:dict];
13 |
14 | return self;
15 | }
16 |
17 | - (NSDictionary *)toDictionary {
18 | NSMutableDictionary *dict = [NSMutableDictionary new];
19 |
20 | return dict;
21 | }
22 |
23 | #pragma mark - Private
24 |
25 | - (void)unpackFromDictionary:(NSDictionary *)dictionary {
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/readable_snippets/JSON_operation.m:
--------------------------------------------------------------------------------
1 | //JSON operation
2 | //AFNetworking JSON operation
3 | //
4 | //Completion scopes: ["CodeBlock"]
5 | //
6 | Copy / Paste in Xcode:
7 |
8 | [[AFJSONRequestOperation JSONRequestOperationWithRequest:nil
9 | success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
10 |
11 | }
12 | failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {
13 |
14 | }] start];
15 |
--------------------------------------------------------------------------------
/readable_snippets/Method_declaration.m:
--------------------------------------------------------------------------------
1 | //Method declaration
2 | //Quicker way to declare a method
3 | //
4 | //Completion scopes: ["ClassImplementation"]
5 | //
6 | Copy / Paste in Xcode:
7 |
8 | - (<#class#> *)<#metod name#>
9 |
--------------------------------------------------------------------------------
/readable_snippets/NSLog.m:
--------------------------------------------------------------------------------
1 | //NSLog
2 | //A Quicker way to log out the stuff
3 | //
4 | //Completion scopes: ["CodeBlock"]
5 | //
6 | Copy / Paste in Xcode:
7 |
8 | NSLog(@"<# your text here #> %@", <#variables here#>);
9 |
--------------------------------------------------------------------------------
/readable_snippets/NSString_with_format.m:
--------------------------------------------------------------------------------
1 | //NSString with format
2 | //Quicker way to do NSString with format
3 | //
4 | //Completion scopes: ["CodeExpression"]
5 | //
6 | Copy / Paste in Xcode:
7 |
8 | [NSString stringWithFormat:@"<#your string and %@'s here#>", <#arguments#>]
9 |
--------------------------------------------------------------------------------
/readable_snippets/Pragma_-_View_Lifecycle.m:
--------------------------------------------------------------------------------
1 | //Pragma - View Lifecycle
2 | //Pragma mark for View Lifecycle
3 | //
4 | //Completion scopes: ["ClassImplementation"]
5 | //
6 | Copy / Paste in Xcode:
7 |
8 | #pragma mark - View Lifecycle
9 |
--------------------------------------------------------------------------------
/readable_snippets/Pragma_Mark.m:
--------------------------------------------------------------------------------
1 | //Pragma Mark
2 | //Quicker way to add a pragma mark
3 | //
4 | //Completion scopes: ["ClassImplementation"]
5 | //
6 | Copy / Paste in Xcode:
7 |
8 | #pragma mark - <#pragma name#>
9 |
10 |
--------------------------------------------------------------------------------
/readable_snippets/Private_Category.m:
--------------------------------------------------------------------------------
1 | //Private Category
2 | //Used for declaring private methods
3 | //
4 | //Completion scopes: ["TopLevel"]
5 | //
6 | Copy / Paste in Xcode:
7 |
8 | @interface <#Class Name#> ()
9 | - (<#type#>)<#method name#>;
10 | @end
11 |
--------------------------------------------------------------------------------
/readable_snippets/Private_Pragma_mark.m:
--------------------------------------------------------------------------------
1 | //Private Pragma mark
2 | //#pragma mark - Private
3 | //
4 | //Completion scopes: ["ClassImplementation"]
5 | //
6 | Copy / Paste in Xcode:
7 |
8 | #pragma mark - Private
9 |
--------------------------------------------------------------------------------
/readable_snippets/Property_Custom_class.m:
--------------------------------------------------------------------------------
1 | //Property Custom class
2 | //Strong, Nonatomic property declaration
3 | //
4 | //Completion scopes: ["ClassInterfaceMethods"]
5 | //
6 | Copy / Paste in Xcode:
7 |
8 | @property (strong, nonatomic) <#class#> *<#property#>;
9 |
--------------------------------------------------------------------------------
/readable_snippets/Property_From_dictionary.m:
--------------------------------------------------------------------------------
1 | //Property From dictionary
2 | //Quickly set self.property with value for key
3 | //
4 | //Completion scopes: ["CodeBlock"]
5 | //
6 | Copy / Paste in Xcode:
7 |
8 | self.<#property#> = dictionary[@"<#key#>"];
9 |
--------------------------------------------------------------------------------
/readable_snippets/Property_IBOutlet_custom_class.m:
--------------------------------------------------------------------------------
1 | //Property IBOutlet custom class
2 | //Strong, Nonatomic IBOutlet property declaration
3 | //
4 | //Completion scopes: ["ClassInterfaceMethods"]
5 | //
6 | Copy / Paste in Xcode:
7 |
8 | @property (strong, nonatomic) IBOutlet <#klass#> *<#property#>;
9 |
--------------------------------------------------------------------------------
/readable_snippets/Property_NSArray.m:
--------------------------------------------------------------------------------
1 | //Property NSArray
2 | //Strong, Nonatomic NSArray property declaration
3 | //
4 | //Completion scopes: ["ClassInterfaceMethods"]
5 | //
6 | Copy / Paste in Xcode:
7 |
8 | @property (strong, nonatomic) NSArray *<#property#>;
9 |
--------------------------------------------------------------------------------
/readable_snippets/Property_NSNumber.m:
--------------------------------------------------------------------------------
1 | //Property NSNumber
2 | //Strong, Nonatomic NSNumber property declaration
3 | //
4 | //Completion scopes: ["ClassInterfaceMethods"]
5 | //
6 | Copy / Paste in Xcode:
7 |
8 | @property (strong, nonatomic) NSNumber *<#property#>;
9 |
--------------------------------------------------------------------------------
/readable_snippets/Property_String.m:
--------------------------------------------------------------------------------
1 | //Property String
2 | //Strong, nonatomic string property declaration
3 | //
4 | //Completion scopes: ["ClassInterfaceMethods"]
5 | //
6 | Copy / Paste in Xcode:
7 |
8 | @property (strong, nonatomic) NSString *<#property#>;
9 |
--------------------------------------------------------------------------------
/readable_snippets/Release_object.m:
--------------------------------------------------------------------------------
1 | //Release object
2 | //Used for releasing an object
3 | //
4 | //Completion scopes: ["CodeBlock"]
5 | //
6 | Copy / Paste in Xcode:
7 |
8 | [<#object#> release];
9 |
--------------------------------------------------------------------------------
/readable_snippets/Singleton.m:
--------------------------------------------------------------------------------
1 | //Singleton
2 | //Quickly declare a singleton
3 | //
4 | //Completion scopes: ["ClassImplementation"]
5 | //
6 | Copy / Paste in Xcode:
7 |
8 | #pragma mark - Singleton
9 | static <#self class#> *singleton;
10 |
11 | + (instancetype)instance {
12 | static dispatch_once_t singletonToken;
13 | dispatch_once(&singletonToken, ^{
14 | singleton = [[self alloc] init];
15 | });
16 |
17 | return singleton;
18 | }
19 |
--------------------------------------------------------------------------------
/readable_snippets/Synthesizer_with__prefix.m:
--------------------------------------------------------------------------------
1 | //@Synthesizer with _prefix
2 | //Synthesize with property=_property
3 | //
4 | //Completion scopes: ["ClassImplementation"]
5 | //
6 | Copy / Paste in Xcode:
7 |
8 | @synthesize <#property#> = _<#property#>;
9 |
--------------------------------------------------------------------------------
/readable_snippets/UITableView_delegate_and_datasource_default_methods.m:
--------------------------------------------------------------------------------
1 | //UITableView delegate and datasource default methods
2 | //Used when adding an tableView in existing controller
3 | //
4 | //Completion scopes: ["ClassImplementation"]
5 | //
6 | Copy / Paste in Xcode:
7 |
8 | #pragma mark - Tableview datasource
9 |
10 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
11 | static NSString *CellIdentifier = @"Cell";
12 |
13 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
14 | cell.<# property #> = <# model #>;
15 | return cell;
16 | }
17 |
18 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
19 | return <#numberOfSections#>;
20 | }
21 |
22 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
23 | return <#numberOfRows#>;
24 | }
25 |
26 |
27 | #pragma mark - Tableview delegate
28 |
29 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {}
30 |
--------------------------------------------------------------------------------
/readable_snippets/UIViewController_pragma_marks.m:
--------------------------------------------------------------------------------
1 | //UIViewController pragma marks
2 | //Pragma marks for the better code organisation. Private on the top eliminates the need of declaring a private interface.
3 | //
4 | //Completion scopes: ["ClassImplementation"]
5 | //
6 | Copy / Paste in Xcode:
7 |
8 | #pragma mark - Private
9 |
10 |
11 |
12 | #pragma mark - View lifecycle
13 |
14 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
15 | return (interfaceOrientation == UIInterfaceOrientationPortrait);
16 | }
17 |
18 |
19 | #pragma mark - Public
20 |
21 |
22 | #pragma mark - IBActions
23 |
--------------------------------------------------------------------------------
/readable_snippets/Value_for_key.m:
--------------------------------------------------------------------------------
1 | //Value For Key
2 | //Modern OBJC syntax for getting a value from dict
3 | //
4 | //Completion scopes: ["CodeExpression"]
5 | //
6 | Copy / Paste in Xcode:
7 |
8 | <#dictionary#>[@"<#the key#>"]
9 |
--------------------------------------------------------------------------------
/readable_snippets/View_Did_Appear.m:
--------------------------------------------------------------------------------
1 | //View Did Appear
2 | //Quickly insert that piece of code!
3 | //
4 | //Completion scopes: ["ClassImplementation"]
5 | //
6 | Copy / Paste in Xcode:
7 |
8 | - (void)viewDidAppear:(BOOL)animated {
9 | [super viewDidAppear:animated];
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/readable_snippets/View_Did_Load.m:
--------------------------------------------------------------------------------
1 | //View Did Load
2 | //Quickly type view did load snippet
3 | //
4 | //Completion scopes: ["ClassImplementation"]
5 | //
6 | Copy / Paste in Xcode:
7 |
8 | - (void)viewDidLoad {
9 | [super viewDidLoad];
10 | <#code#>
11 | }
12 |
--------------------------------------------------------------------------------
/readable_snippets/View_Did_Unload.m:
--------------------------------------------------------------------------------
1 | //View Did Unload
2 | //Quick ViewDidUnload declaration
3 | //
4 | //Completion scopes: ["ClassImplementation"]
5 | //
6 | Copy / Paste in Xcode:
7 |
8 | - (void)viewDidUnload {
9 | [super viewDidUnload];
10 | <#code#>
11 | }
12 |
--------------------------------------------------------------------------------
/readable_snippets/View_Will_Appear.m:
--------------------------------------------------------------------------------
1 | //View Will Appear
2 | //quickly define method
3 | //
4 | //Completion scopes: ["ClassImplementation"]
5 | //
6 | Copy / Paste in Xcode:
7 |
8 | - (void)viewWillAppear:(BOOL)animated {
9 | [super viewWillAppear:animated];
10 |
11 | <# code #>
12 | }
13 |
--------------------------------------------------------------------------------
/readable_snippets/View_Will_Dissappear.m:
--------------------------------------------------------------------------------
1 | //View Will Dissappear
2 | //quickly define method
3 | //
4 | //Completion scopes: ["ClassImplementation"]
5 | //
6 | Copy / Paste in Xcode:
7 |
8 | - (void)viewWillDisappear:(BOOL)animated {
9 | <# code #>
10 |
11 | [super viewWillDisappear:animated];
12 | }
13 |
--------------------------------------------------------------------------------
/readable_snippets/View_did_dissapear.m:
--------------------------------------------------------------------------------
1 | //View did dissapear
2 | //Quick declaration
3 | //
4 | //Completion scopes: ["ClassImplementation"]
5 | //
6 | Copy / Paste in Xcode:
7 |
8 | -(void) viewDidDisappear:(BOOL)animated {
9 |
10 | [super viewDidDisappear:animated];
11 | }
12 |
--------------------------------------------------------------------------------
/readable_snippets/Void_method_declaration.m:
--------------------------------------------------------------------------------
1 | //Void method declaration
2 | //Quickly declare a void method
3 | //
4 | //Completion scopes: ["ClassInterfaceMethods", "ClassImplementation"]
5 | //
6 | Copy / Paste in Xcode:
7 |
8 | - (void)<#metod name#>
9 |
--------------------------------------------------------------------------------