From: http://www.flyblog.info/
When I saw a friend who was just developing the iPhone software asking a lot of questions, I actually encountered the same problem. So I took the time to summarize the problems that I could think of or encountered, you can give yourself a memo or share it with friends.
1. Can I use C/C ++ for iPhone SDK development?
Answer: The basic framework for iPhone SDK development is based on the cocoa library, and objective-C is the cocoa development language. However, based on objective-c featuresProgramYou can use C/C ++ for function development and third-party C/C ++ libraries.
2. How can I use C/C ++?
Answer: When you need to use C/C ++, you can change the file name of the class implementation to. Mm, so that the compiler knows that the modified file contains C/C ++Code(Note: In this case, the compilation option of the Project attribute must be set to GCC 4.0-language-> compile sources as based on the file type, Objective C ++, or C ++)
3. What does objective-C Class Attribute keyword mean when nonatomic is used?
Answer: This is the objective-C feature. The keyword is used to tell the compiler how to handle thread security when automatically generating the accesser code. By default, all attributes are atomic, Which is thread-safe, but the running efficiency is low. Considering the efficiency, nonatomic is generally used and thread-safe processing is performed on its own.
4. How to Avoid program crashes due to insufficient memory?
Answer: The memory available for iPhone applications is very small. Apple does not provide a clear upper limit, but according to the summary of other developers on the Internet, this number cannot exceed 20 MB, which is unconfirmed, however, I have encountered frequent crash when the program allocates 13 MB of memory. Therefore, to avoid instability caused by insufficient memory, follow Apple's advice.
- Load resources lazily, that is, all resources are loaded when used, and are released immediately after use. For example, your program requires three images to be displayed in a view. In the past, the desktop program used to load the three images to the memory when the program was started, directly call the memory to improve efficiency. However, this method is not available in the iPhone. The iPhone's principle for resources is:Use-as-you-go and release after use.
- We also try to avoid using autorelease for object allocation and make good use of the memory pool of the NSAID utoreleasepool. Especially in loops.
- Large data volumes are stored using SQLite, which features fast storage and high efficiency.
- To avoid Memory leakage, iPhone program crashes because of Memory leakage. You can use xcode> RUN> start with performance tool> leaks to check the leakage.
5. How to save user input information in the program?
Answer: sometimes it is necessary to save user input information data or program status, the best way is to use plist storage. Plist storage has many advantages. nsarray, nsdictionary, and other container classes support direct input and output of plist files. Note that the format of the input and output files must be consistent with that of the corresponding container class. That is to say, the plist file output using [array writetofile] must be read using [array arraywithcontentsoffile:]. If array and dictionary are mixed, the program will crash.
6. How does one bring up the network link dialog box?
Answer: If the network is used in the program, the network connection dialog box prompts the user according to the app store requirements. You only need to add an entry to the info. plist file: The uirequirespersistentwifi type is Boolean and the value is yes.
7. How to display the Network busy indicator in the top status bar?
Answer: SetNetworkactivityindicatorvisible = YesYou can assign a value of no if you do not need it.
8. How do I display numbers on the program icon?
Answer: modified when the program exits or changes[Uiapplication sharedapplication]. applicationiconbadgenumberCan be
9. How do I compare two nsstring strings?
Answer: Use isequaltostring of the nsstring class: method to determine whether the string is the same. You can also use [nsstringobject compare:] = nssameorder. Note: isequal is used to determine whether the two objects are the same, not the content.
10. How can I change the background color of a navigation bar?
Answer: If it is modified in viewcontroller, the following code is used:
Self . navigationcontroller. navigationbar. tintcolor = [ uicolor colorwithred :< span> 0.03 green : 0.215 blue : 0.298 alpha : 1 ];