However, feeding both files into the converter at the same time would have produced the correct result.Īs a general rule of thumb, try to always convert files with the least number of dependencies and then go from there. This is because the converter has no idea that myBooleanProperty actually has type Bool and not just a normal, nullable object. Now consider another SecondClass which uses FirstClass in its implementation as follows: // SecondClass.mĬonverting SecondClass on its own would produce the following wrong result: // SecondClass.swift Imagine having FirstClass.h with the following property defined in its header: // ( nonatomic, assign) BOOL myBooleanProperty However, using the Advanced Project Converter to convert one file at a time is still considered the most convenient approach for 95% of cases, just because of the simplicity. Let's assume that each of these classes depends on declarations found in the other one it would make sense to convert both these files at the same time so that the converter has all the information it needs for a slightly better conversion result. For example, take the two classes: FirstClass and SecondClass. This approach is preferable when you have interdependent files. Converting multiple classes at the same time It's clearly unrealistic to expect that all of the files in your project are independent in fact, it's usually the case that only a small number of utility and helper classes in a project are independent and the rest aren't. This article explains what kind of information the converter needs to produce correct results. Since there are no dependencies, the converter will have all the information needed to convert this file. Start with a file that doesn’t have any dependencies on other Objective-C files in your project. Here's how, and when, you should take this approach: Converting one class at a timeĪs mentioned, this is the preferred approach as it almost always leads to the least amount of issues during, and after, conversion. However, depending on the situation, it might be better to convert multiple files together. It is always better to try to convert each file individually. The most important thing to remember is that this process is a marathon and not a sprint. This article discusses some guidelines that will make your life easier when migrating an Objective-C project to Swift.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |