Referring to weak self inside a nested block

Your code will work fine: the weak reference will not cause a retain cycle as you explicitly instruct ARC not to increase the retainCount of your weak object. For best practice, however, you should create a strong reference of your object using the weak one. This won’t create a retain cycle either as the strong … Read more

How to make text input box to occupy all the remaining width within parent block?

Updated [Oct 2016]: Flexbox version… form { display: flex; } form input[type=”text”] { flex: 1; } <form> <label>Name</label> <input type=”text” /> <button>Submit</button> </form> <p>Lorem ipsum…</p> Original answer [Apr 2011]: Table-less CSS version (of table behavior)… <div id=”parent”> <div id=”inner”> <label>Name</label> <span><input id=”text” type=”text” /></span> <input id=”submit” type=”button” value=”Submit” /> </div> <p>some paragraph text</p> </div> CSS… … Read more

How to center things – display:block/inline-block

Block elements should always be centered using .block { margin-left: auto; margin-right: auto; width: 600px; } as stated by the w3c: http://www.w3.org/Style/Examples/007/center.en.html#block text-align: center; is well-named: use it to center texts. Update You can also use display: flex now: .parent { display: flex; justify-content: center; } .block { width: 200px; }

optional closure and check if it is nil

You need to wrap your closure signature in parentheses to make the closure itself optional. The way it’s written now, the closure returns an optional Void (which doesn’t really make sense). var completionHandler: ((sucsess:Bool!, items:[AnyObject]!)->())? Some style points and revisions to your example code: // Capitalize class names so it’s clear what’s a class class … Read more

Compiler error when declaring a variable inside if condition and no curly braces

Because the language spec says so: http://docs.oracle.com/javase/specs/jls/se7/html/jls-6.html A declaration introduces an entity into a program and includes an identifier (ยง3.8) that can be used in a name to refer to this entity. A declared entity is one of the following: … A local variable, one of the following: * A local variable declared in a … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)