What happens if I don’t retain IBOutlet?

It is recommended you declare properties for all of your IBOutlets for clarity and consistency. The details are spelled out in the Memory Management Programming Guide. The basic gist is, when your NIB objects are unarchived, the nib loading code will go through and set all of the IBOutlets using setValue:forKey:. When you declare the … Read more

Objective-C 101 (retain vs assign) NSString

There’s no such thing as the “scope of an object” in Objective-C. Scope rules have nothing to do with an object’s lifetime — the retain count is everything. You usually need to claim ownership of your instance variables. See the Objective-C memory management rules. With a retain property, your property setter claims ownership of the … Read more

Selected value for JSP drop down using JSTL

In HTML, the selected option is represented by the presence of the selected attribute on the <option> element like so: <option … selected>…</option> Or if you’re HTML/XHTML strict: <option … selected=”selected”>…</option> Thus, you just have to let JSP/EL print it conditionally. Provided that you’ve prepared the selected department as follows: request.setAttribute(“selectedDept”, selectedDept); then this should … Read more

@property definitions with ARC: strong or retain?

1) Shouldn’t retain now be replace with strong or weak? No. You cannot replace retain with weak; they are different. And strong is a 100% synonym for retain; they are identical. You can use either, so there is no “should” here. You can replace retain with strong if you like, but you don’t have to. … Read more

capturing self strongly in this block is likely to lead to a retain cycle

The capture of self here is coming in with your implicit property access of self.timerDisp – you can’t refer to self or properties on self from within a block that will be strongly retained by self. You can get around this by creating a weak reference to self before accessing timerDisp inside your block: __weak … Read more

When to access properties with ‘self’

you almost always want to access variables using the synthesized setters/getters, even if you aren’t doing anything special with them at the moment. if as your application develops, you find that you need to be doing further validation/formatting of variables, then you can just implement the required setter/getter method, and if you have used the … Read more

Fix warning “Capturing [an object] strongly in this block is likely to lead to a retain cycle” in ARC-enabled code

Replying to myself: My understanding of the documentation says that using keyword block and setting the variable to nil after using it inside the block should be ok, but it still shows the warning. __block ASIHTTPRequest *request = [[ASIHTTPRequest alloc] initWithURL:… [request setCompletionBlock:^{ NSDictionary *jsonDictionary = [[CJSONDeserializer deserializer] deserialize:request.responseData error:nil]; request = nil; // …. … Read more

How can I retain HTML form field values in JSP after submitting form to Servlet?

You could access single-value request parameters by ${param}. <%@ taglib uri=”http://java.sun.com/jsp/jstl/functions” prefix=”fn” %> … <input name=”foo” value=”${fn:escapeXml(param.foo)}”> <textarea name=”bar”>${fn:escapeXml(param.bar)}</textarea> … <input type=”radio” name=”faz” value=”a” ${param.faz == ‘a’ ? ‘checked’ : ”} /> <input type=”radio” name=”faz” value=”b” ${param.faz == ‘b’ ? ‘checked’ : ”} /> <input type=”radio” name=”faz” value=”c” ${param.faz == ‘c’ ? ‘checked’ : ”} … Read more

tech