Objective-C function with default parameters? [duplicate]

There’s no default parameters in ObjC. You can create 2 methods though: -(void)fooWithA:(int)a b:(int)b c:(int)c { … } -(void)fooWithA:(int)a b:(int)b { [self fooWithA:a b:b c:0]; } For C : there’s nothing special added to the C subset by using ObjC. Anything that cannot be done in pure C can’t be done by compiling in ObjC …

Read more

inserting newlines in xml file generated via xml.etree.ElementTree in python

UPDATE 2022 – python 3.9 and later versions For python 3.9 and later versions the standard library includes xml.etree.ElementTree.indent: Example: import xml.etree.ElementTree as ET root = ET.fromstring(“<fruits><fruit>banana</fruit><fruit>apple</fruit></fruits>”””) tree = ET.ElementTree(root) ET.indent(tree, ‘ ‘) # writing xml tree.write(“example.xml”, encoding=”utf-8″, xml_declaration=True) Thanks Michał Krzywański for this update! BEFORE python 3.9 I found a new way to avoid …

Read more