objective-c

release vs setting-to-nil to free memory

In my root view controller, in my didReceiveMemoryWarning method, I go through a couple data structures (which I keep in a global singleton called DataManager), and ditch the heaviest things I've got--one or maybe two images associated with possibly twenty or thirty or more data records. Right now I'm going through and setting those to ...

Cocoa nonatomic properties

When you look at some Objective-C code, you often see class properties defined as non-atomic. Why? Does it give you some performance boost when you're not working with threads, or is there some other reason? ...

Fetch Data using predicate. Retrieve single value.

I want to retrieve a single value (String) from "Entry." I believe I am missing something. Can someone point it out? XYZAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate]; NSManagedObjectContext *managedObjectContext = appDelegate.managedObjectContext; NSFetchRequest *request = [[NSFetchRequest alloc] init]; NSPre...

Access problem with NSMutableArray

Hi, my problem is that I can't access my NSMutableArray in - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {}. I create my NSMutableArray here: nodes = [xmlDoc nodesForXPath:@"/xml/items/item/short_desc" error:nil]; if (nodes != nil && [nodes count] >= 1) { for (int i = 0; i <...

Detecting (null) in Objective-C

I want to detect whether passing a NSString to NSLog will return (null). I've tried if (string == @"") {do something}" and if (string == @"(null)") {do something}" but neither seem to work. Any advice would be greatly appreciated! ...

UIBarButtonItem does not appear to respond to "style" property.

Situation: I'm placing an instance of a system "item action" button into the right navigation button slot... no problems there. However, I want that button to display as just the icon WITHOUT a border around it (ie: "plain" style). Reading over documentation, it sounds like this should be a simple matter of just setting the UIBarButtonIt...

handleOpenURL not called using a custom url schema in iPhone OS

Hi, I have successfuly added my own url schemes to my App. The App correctly launches using the schemes. Now I want to handle the incoming data but the delegate is not called. It is an universal app and I have added the following function to both AppDelegates: - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url...

Why is this leaking memory? UIImage `cellForRowAtIndexPath:`

Hey. Instruments' Leaks tells me that this UIImage is leaking: UIImage *image = [[UIImage alloc] initWithContentsOfFile:[imagesPath stringByAppendingPathComponent:[NSString stringWithFormat:@"/%@.png", [postsArrayID objectAtIndex:indexPath.row]]]]; // If image contains anything, set cellImage to image. If image is empty, try one more ...

How come this object is released right after it's instantiated? From a book example I'm learning from:

BlueViewController *blueController = [[ BlueViewController alloc] initWithNibName:@"BlueView" bundle:nil]; self.blueViewController = blueController; [self.view insertSubview:blueController.view atIndex:0]; [blueController release]; ...

making an Objective C program respond to applescript

I have an Objective C program, and I'm trying to add scriptability. I have read the docs, and I've seen the SimpleScripting examples. so, I have two questions: 1) Am I correct in saying that every (non-standard) command is going to need it's own class to respond to that command? And that class will probably only have one method. 2) Wha...

Parsing NSXMLNode Attributes in Cocoa

Hello everyone, Given the following XML file: <?xml version="1.0" encoding="UTF-8"?> <application name="foo"> <movie name="tc" english="tce.swf" chinese="tcc.swf" a="1" b="10" c="20" /> <movie name="tl" english="tle.swf" chinese="tlc.swf" d="30" e="40" f="50" /> </application> How can I access the attributes ("english", "chines...

Non-fullscreen UINavigationController

Is it possible to use a UINavigationController in such a way that it doesn't use the full window? I've tried setting it's view's frame as well as adding it's view to another (non-fullscreen) view instead of the window, and neither seems to work. ...

Having Issues with a utility app...

How do I accept data on the backside of a utility app, and then how do I let users modify that data? I've tried all sorts of tutorials, but to no avail. If you need further information let me know. Thanks in advanced. ...

How much overhead does a msg_send call incur?

I'm attempting to piece together and run a list of tasks put together by a user. These task lists can be hundreds or thousand of items long. From what I know, the easiest and most obvious way would be to build an array and then iterate through them: NSArray *arrayOfTasks = .... init and fill with thousands of tasks for (id *eachTask ...

Is `super` local variable?

// A : Parent @implementation A -(id) init { // change self here then return it } @end A A *a = [[A alloc] init]; a. Just wondering, if self is a local variable or global? If it's local then what is the point of self = [super init] in init? I can successfully define some local variable and use like this, why would I need to assign...

Purpose of CALayer?

Hi, I'm slightly used as to what the purpose of CALayer's existence is. Why not just put the properties in a UIView? Thanks. ...

Best way to change the background color for an NSView

I'm looking for the best way to change the background color of an NSView. I'd also like to be able to set the appropriate alpha mask for the NSView. Something like: myView.backgroundColor = [NSColor colorWithCalibratedRed:0.227f green:0.251f blue:0.337 alpha:0.8]; I notice that NSWindow has this method, and I'm not a big fan of the ...

UITableViewCell is transparent when not supposed to be

My UITableViewCell is being transparent when it's not supposed to be. My table view has a background color and it shows through the table cell, even though they're supposed to be opaque. I'm not sure why this is. Relevant code: UITableViewCell *cell = [table dequeueReusableCellWithIdentifier:emptyIdentifier]; if (cell == nil) {...

How to treat CoreData entities with low memory usage

Hello, I tried CoreData for iPhone app, but it's memory-hogging when entity instances are fetched. After they are released, memory usage doesn't decrease at all. Is there any way to treat them in a low memory usage. Thank you. ...

Quartz 2D Layers

I want to create 2 separate layers using quartz 2D. Can i handle there redraw methods separately? so that i can redraw 1 layer without redrawing the whole screen or other layers. Is it possible? any code sample? ...