Wednesday, February 29, 2012
SubView-k kilogolasa
Friday, February 24, 2012
Igy kapjuk meg egy UITableView egyik cellajat
Thursday, February 9, 2012
Wednesday, February 1, 2012
Keyboard eltuntetes UITextField-nel
- UITextField delagate-jet ra kell allitani a File's Owner-re
-textFieldShoudReturn(UITextFiled *)textField-ben meg kell hivni a textField-en a resignFirstResponder-t valahogy igy:
Wednesday, November 30, 2011
Categories (By Scott Stevenson)
This is particularly useful because you can add methods to built-in objects. If you want to add a method to all instances of NSString in your application, you just add a category. There's no need to get everything to use a custom subclass.
For example, if I wanted to add a method to NSString to determine if the contents is a URL, it would look like this:
Here's the implementation. Keep in mind this is not a good implementation of URL detection. We're just trying to get the concept of categories across:
Remember, when you make changes to a class using a category, it affects all instances of that class throughout the application.
Tuesday, November 29, 2011
Thursday, November 3, 2011
NSTemporaryDirecotory
Do you use the temporary directory? On Simulator NSTemporaryDirectory() returns Mac OS X tmp, a path in /var, which is outside the application sandbox.
#if TARGET_IPHONE_SIMULATOR
NSString *tmpPath = [NSHomeDirectory() stringByAppendingPathComponent: @"tmp"];
#else
NSString *tmpPath = NSTemporaryDirectory();
#endif
Tuesday, October 25, 2011
Halozat sebessegenek korlatozasa
sudo ipfw add 500 pipe 1 ip from any to any sudo ipfw pipe 1 config bw 112kbit/s plr 0 delay 20ms |
sudo ipfw delete 500 |
Friday, October 21, 2011
Thursday, October 20, 2011
Tuesday, October 18, 2011
Matt Gallagher: Variable argument lists in Cocoa
The va_list, va_start, va_arg and va_end are all standard C syntax for handling variable arguments. To describe them simply:
va_list- A pointer to a list of variable arguments.va_start- Initializes ava_listto point to the first argument after the argument specified.va_arg- Fetches the next argument out of the list. You must specify the type of the argument (so thatva_argknows how many bytes to extract).va_end- Releases any memory held by theva_listdata structure.
Generally speaking, you can use this for loop for any variable argument situation where your arguments are all the same type. Other cases are a bit trickier but far less common — I'm sure you can work out how they would work if needed.
va_list in Cocoa
A number of classes in Cocoa have methods that take variable numbers of arguments. In most cases, these classes will also have an equivalent method that takes a va_list.
We can see an example of these va_list equivalents by looking at NSString. NSString declares the class method stringWithFormat:... (which takes a variable number of arguments) andNSString also declares the instance method initWithFormat:arguments: (where the argumentsparameter is a va_list) which handles the equivalent behavior of stringWithFormat:....
These va_list methods are used in the situation where your class defines a method with a variable argument list and you need to pass those variable arguments into the Cocoa method. For example, if the StringContainer class listed above declared the method:
- (void)setContentsWithFormat:(NSString *)formatString, ...; |
The implementation of this method would be as follows:
- (void)setContentsWithFormat:(NSString *)formatString, ...{ [contents autorelease]; va_list args; va_start(args, formatString); contents = [[NSString alloc] initWithFormat:formatString arguments:args]; va_end(args);} |
The va_list parameter allows us to pass our own variable argument list to the Cocoa method so that the Cocoa method can handle the arguments.