Objective C - Not releasing memory when popping UITableViewController scene - objective-c

I have a simple project using Xcode 4.3.2 targeting iOS 5.1, using storyboards and a NavigationController. I have just migrated the project to use ARC and I'm now noticing that memory isn't being reclaimed when my UITableViewController scene is popped (back button pressed). I'm sure this was working OK when I was managing memory myself. I'm using the 'Allocations' feature of the Instruments tool and I can see the 'Live Bytes' continues to increase each time the scene is pushed then popped. The interface for the UITableViewController is :
#import <UIKit/UIKit.h>
#import "ASIHTTPRequest.h"
#interface StockListView : UITableViewController <UISearchBarDelegate>
{
NSMutableArray *tableListArray;
IBOutlet UISearchBar *searchBarControl;
}
#property (nonatomic) ASIHTTPRequest *httpDSRequest;
#end
The UITableView uses a custom UITableViewCell class defined as follows :
#import <UIKit/UIKit.h>
#interface StockListCell : UITableViewCell
#property (nonatomic) IBOutlet UILabel *lblStockCode;
#property (nonatomic) IBOutlet UILabel *lblDescription;
#property (nonatomic) IBOutlet UILabel *lblQtyInStock;
#property (nonatomic) IBOutlet UILabel *lblQtyFree;
#end
Is there something in the properties I'm using that is keeping the view controller retainined in memory? Do I need to add some code to allow the view controller to fully deallocate now that I'm using ARC?
I also used the 'Leaks' feature of Instruments but this didn't show up any leaks present.
Any help appreciated, apologies I'm still new to iOS development.
Thanks
Jonathan

You should make the buttons weak referenced
#property (weak, nonatomic) IBOutlet UILabel *lblStockCode;
And maybe have a look at this: ARC Transition

Related

Xcode displays error when building Mac app for release

I'm writing an application for OS X using core data. It's no problem to build and run it for debugging but when I switch to release or try to archive it, it throws the error
'/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/CoreData.framework/Headers/NSFetchRequestExpression.h:15:39: Attempting to use the forward class 'NSExpression' as superclass of 'NSFetchRequestExpression'
When I delete all fetch request from the code, it works fine.
Does anybody know what problem this could be? Thank you.
Here are the header:
#import <Cocoa/Cocoa.h>
#import <CoreData/CoreData.h>
#import "EFMainController.h"
#interface EF_AppDelegate : NSObject
{
IBOutlet NSMenu *statusMenu;
NSStatusItem *statusItem;
NSWindow *window;
NSPersistentStoreCoordinator *persistentStoreCoordinator;
NSManagedObjectModel *managedObjectModel;
NSManagedObjectContext *managedObjectContext;
EFMainController *mainController;
NSTabView *tabView;
IBOutlet NSImageView *dockTileView;
}
#property (nonatomic, retain) IBOutlet NSWindow *window;
#property (nonatomic, retain) IBOutlet EFMainController *mainController;
#property (assign) IBOutlet NSTabView *tabView;
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator;
- (NSManagedObjectModel *)managedObjectModel;
- (NSManagedObjectContext *)managedObjectContext;
- (IBAction)saveAction:sender;
#end
and
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#interface EFMainController : NSObject {
/* some variables */
}
/* some properties and actions */
#end
The stuff where I put the comments has nothing to do with core data
I have a program where I experience the same Problem and so far I could not really solve it but I was able to somewhat build it for release. So I guess this is not a real/full answer but for me it worked to use Product > Build For > Archiving.

IBOutlets defined in controller's .h file are not visible in Inspector

I am creating a iPad app, using XCode4 and Storyboard. I have the exact same app on a iPhone, which works just fine. I copied all of the controller's .h and .m files to the new iPad app. There are NO build errors. I am using custom cells in several UITableViews, with prototype cells.
I have 4 IBOutlets defined in a .h file, which is included in the UIView controller's .h file. I'm trying to connect the IBOutlets to the objects in the prototype cells, but when I click on the controller, the objects don't appear in the Inspector.
Any idea why?
UPDATE: here is the code for the SiteListingCell.h.
#import <UIKit/UIKit.h>
#interface SiteListingsCell : UITableViewCell {
}
#property (nonatomic, strong) IBOutlet UILabel *staLabel;
#property (nonatomic, strong) IBOutlet UILabel *descLabel;
#property (nonatomic, strong) IBOutlet UILabel *dateLabel;
#end
Make sure the class of the object you're trying to connect is set correctly in IB:

WebView outlet mysteriously not available in XIB

Just trying to make a simple WebView Mac app.
I've imported WebKit.h, declared a WebView #property, and #synthesized it in the .m, but when I go into IB and the connections tab, my outlet, say MyWebView, is not listed.
.h
#import <Cocoa/Cocoa.h>
#import <WebKit/WebKit.h>
#interface MyAppDelegate : NSObject <NSApplicationDelegate> {
NSWindow *window;
IBOutlet WebView *MyView;
}
#property (assign) IBOutlet NSWindow *window;
#property (nonatomic, retain) IBOutlet WebView *MyView;
#end
.m
#synthesize MyView;
Latest version of Xcode. Thoughts?
Make sure that is defined like:
#property(nonatomic, retain) IBOutlet UIWebView *myWebView;
If you haven't added IBOutlet, IB won't show it as such.
After looking at the code you posted a little more carefully, I think the problem has to do with the name of your app delegate -- how (and why?) did you change it from the default AppDelegate? Is the blue cube in IB named AppDelegate or is it named MyAppDelegate? If it's the former, that's your problem -- change its class to MyAppDelegate in the Identity Inspector in IB.
See my comments on my original question. Error on my part.

Why am I getting these errors when trying to add a UIWebView to this ViewController header file?

I was following the steps here: http://matt.might.net/articles/how-to-native-iphone-ipad-apps-in-javascript/
Here are the bare bones steps to turning a web app into a native app:
Open XCode.
Create a new "View-based Application" iPhone project.
Move the files for your web app into the Resources folder in XCode,
but strip out the cache manifest. (You don't want the manifest
screwing things up, since everything is now local.)
Create a new instance variable, webView, inside the #interface
ViewController header file: IBOutlet UIWebView* webView ; //
IBOutlet means it's visible to Interface Builder.
and create a property: #property (nonatomic, retain) UIWebView
*webView;
Here is what I have thus far (ViewController.h):
#import <UIKit/UIKit.h>
#interface ViewController : UIViewController
IBOutlet UIWebView* webView;
#property (nonatomic, retain) UIWebView *webView;
#end
However on step 4 I am getting two errors in my ViewController header file:
"cannot declare variable inside #interface or #protocol"
and
"iboutlet attribute can only be applied to instance variables or
properties"
So what am I doing wrong, or is that website tutorial wrong?
Note: I downloaded the sample project he had for iPhone and it worked, but I am following the tutorial so I can make an iPad version.
I am in XCode 4 and the error shows whether I do iOS 5 or iOS 4.3 doesn't seem to make a difference.
You're missing a couple of curly braces there:
#import <UIKit/UIKit.h>
#interface ViewController : UIViewController {
UIWebView *webView;
}
#property (nonatomic, retain) IBOutlet UIWebView *webView;
#end
I think you forgot the brackets; try to change your code to
#import <UIKit/UIKit.h>
#interface ViewController : UIViewController {
IBOutlet UIWebView* webView;
}
#property (nonatomic, retain) UIWebView *webView;
#end

How to set declare an IBOutlet to a TextView correctly on Mac OS

I'm going to recreate my iPhone app for the mac. There is only one problem I'm having. This may sound stupid to you but I can't figure it out.
When I want to call a method for the UITextView in iOS i just did like this:
IBOutlet UITextView *myTextView;
and
#property (nonatomic, retain) UITextView *myTextView;
But I can't figure out how to do it for a textfield in Mac OS X developing.
Could someone help me with this?
Thanks!
There is no UIKit on the mac! The functional equivalent (and then some...) of a UITextView in AppKit is NSTextView.
In AppKit, IBOutlets are not retained!
So your interface should become
#interface YourClass : SuperClass {
// other ivars
NSTextView *myTextView;
}
#property (nonatomic, assign) IBOutlet NSTextView *myTextView;
// and so forth...