Custom UITableViewCell from Interface Builder with retain count 2

Hi!
I am creating a customViewCell in my UITableViewController (which I was creating in IB) - the wired thing: it has a retain count of 2! Any hints why?
UIViewController *c = [[UIViewController alloc] initWithNibName:CellIdentifier bundle:nil];
GroupCell *cell;// = [[[GroupCell alloc] init] autorelease];
cell = (GroupCell *) c.view;
[c release];
NSDictionary *groupDict;
NSLog(@"retain count of groupCell: %d, ", [cell retainCount] );
retain count of groupCell = 2!!
my cell has no init method, no "retain" nor do I send anywhere a retain to it..

Hey Alex!
sommeralex wrote:
I am creating a customViewCell in my UITableViewController (which I was creating in IB) - the weird thing: it has a retain count of 2! Any hints why?
Your code is obtaining the retain count by sending the [retainCount|http://developer.apple.com/library/ios/documentation/Cocoa/Referen ce/Foundation/Protocols/NSObjectProtocol/Reference/NSObject.html#//appleref/doc/uid/20000052-BBCDAAJI] message, so this warning in the doc applies:
Important: This method is typically of no value in debugging memory management issues. Because any number of framework objects may have retained an object in order to hold references to it, while at the same time autorelease pools may be holding any number of deferred releases on an object, it is very unlikely that you can get useful information from this method.
I think the above is telling us that retainCount returns an accurate number, but that number is useless because we don't know how many releases are pending. E.g., suppose your code has released an object prematurely, so your logical count should be zero. However, if the runtime system has retained the object 5 times at that stage, retainCount will return 5. The point is that all 5 of those retains will be released at some future time not of our choosing.
You can override retain and release to keep your own count, but I don't know if that count is any more useful than what you get from retainCount.
I think the only retain count that's any of our business is the number of retains and releases we see in our code. In other words, I think the logical count is much more useful than the real count:
UIViewController *c = [[UIViewController alloc]
initWithNibName:CellIdentifier bundle:nil]; // Line A: +1
GroupCell *cell;
cell = (GroupCell *) c.view; // Line B
[c release]; // Line C: -1
NSLog(@"retain count of groupCell: %d, ", [cell retainCount] );
Based on the doc for the ['view' property of UIViewController|http://developer.apple.com/library/ios/documentation/UIKit/Ref erence/UIViewControllerClass/Reference/Reference.html#//appleref/doc/uid/TP40006926-CH3-SW2], the view object should be created and retained once when the nib is loaded in Line A (except if no view object is included in the nib, in which case the view would be created and retained once in Line B). The view would then be released once when the view controller is released in Line C.
So using my arithmetic, the view's retain count is zero after Line C. If that's correct, the only thing saving you from a crash might be one of those system retains we don't know about. You could test my analysis by not giving the view to a table view, then checking to see if it still exists at some point after the end of the current event cycle. You could implement dealloc with a NSLog statement in your custom view to see if and when the view is actually freed.
Absent any further analysis, I would advise retaining and autoreleasing the view before releasing the controller (or just autoreleasing the controller), to make sure the view lasts until retained by your table view.
- Ray

Similar Messages

  • Creating an attribute editor like panel from Interface Builder

    The Attributes Inspector from Interface Builder presents the user with a great set of options that are neatly organized in folding panels. I really want to do something like this for a project I'm working on to help organize a large set of options that I plan on presenting to the end user.
    Only problem is I have no idea what this widget is called or even if its available from Cocoa. I thought it was a NSRuleEditor but I've seen no examples so I'm not sure. So if someone could help point me in the right direction that would be awesome. If you know of an example project in the Examples folder that would be even better. Thanks a lot.

    The IB toolpanel is just built out of stock IB parts but there are quite a few of them. As far as I can tell it's just an NSPanel with a toolbar at the top and then at least one NSSplitView with an NSScrollView inserted into it.
    To add something like this to your project - although I would recommend starting simpler for learning - simply drag an NSPanel into your IB window and then drag an NSScrollView on top of it and it will fill the NSPanel and you can modify it from there. You can also drag an NSScrollView directly into your nib and work on it and then drop it on the NSPanel if you want. This might make the process easier/more clear for you. If you put an NSTextView into the window it will automatically show and hide scrollbars depending on content unless you tell it otherwise.
    Custom views can be confusing but since NSPanels can be made to show themselves as soon as a program launches (I think this is their default state) your content should show up automatically which makes it easier than creating regular windows and then worrying about showing their contents.
    Do this help?
    =Tod

  • Property behaviour curiosity with retain counts

    Hey folks,
    I've been encountering a behaviour with retain counts and properties that I don't expect. I hope someone can clear it up. Assuming this contrived code:
    // Public header
    @interface ObjectB : NSObject
    float m_FloatValue;
    @property(readwrite) floatValue;
    @end
    @interface ObjectA : NSObject
    ObjectB* m_MemberB;
    @property(retain) ObjectB* memberB;
    @end
    // Implementation file
    @implementation ObjectB
    @synthesize floatValue = m_FloatValue
    @end
    @implementation ObjectA
    @synthesize memberB = m_MemberB;
    @end
    Now the trick is that this line of code:
    float valueOfB = anObjectA.memberB.floatValue;
    ... causes m_MemberB to be retained. This seems odd to me, since all I'm trying to do is dig down and pull out the float value of B. Is the default implementation of a (retain)ed property's getter incrementing the retain count? Does it assume I'm storing my reference to that member, so it had better retain it for me to be clever?
    I find this behaviour is causing excess retain counts all over my current app, and I'm having to work around it by implementing my own getters for retained member variables. Am I missing something here, or using something incorrectly? Any information would be much appreciated.
    If it matters, this code is Objective-C 2.0 on the iPhone.
    Thanks!

    I tried your example and reproduced your result, except anObjectA.memberB.floatValue caused m_MemberB to be retained not once, but twice. Then I found that changing from dot to message syntax caused only one retain(??):
    // this causes ObjectB::retain to be called twice
    float valueOfB = anObjectA.memberB.floatValue;
    // this causes ObjectB::retain to be called once
    float valueOfB = [[anObjectA memberB] floatValue];
    The behavior was consistent over several trials with OS 2.1 on both the Simulator and the Device. I also changed the instance variable name to match the property name to rule out a problem with the +@synthesize a=b+ syntax, but this didn't affect the results.
    The advice that's often given in this forum is that observing retain counts is useless since their meaning at any particular stage of execution can't be interpreted (since we don't know how many autoreleases are pending?). In short, "Cocoa knows what it's doing and if you follow the rules you'll wind up with an equal number of retains and releases".
    That said, the above results aren't the kind that inspire much confidence. Hopefully someone who knows what's going on will join this thread soon.

  • Running form from Forms Builder with IE

    Forms 11.1.1.4, IE 8, Windows 7 64-bit.
    1. Running form from Forms Builder with IE results in Page cannot be displayed. My Java console doesn't even appear so it's not getting to the servlet part.
    2. Running same form stand-alone in IE works fine. The URLs are identical (I've cut/pasted them)
    3. Running same form from Forms Builder with Firefox works fine. The only change I made was to the runtime preference for the browser location.
    Seems like this has to be something to do with the browser configuration that only occurs from Forms Builder. What could it be?

    I'm not sure about the specifics of your configuration but I suspect the answer is in formsweb.cfg (and the associated .env file).
    I think that generally the configuration that runs for formbuilder is the "default" whereas you could be specifying a different
    one on the url not going through formbuilder. (but if you're using em then it's really hard to know what's going on since it seems
    to not write changes back to the config and env files until it is stopped. This caused me many days of confusion until I figured it out and
    that's why I would highly advise never using it to modify .config or env settings.)
    check what jre is installed in ie (tools, manage addons, there is on my machine:
    java 2 plugin ssv helper and JQSIEStartDetectorImpl browser helper object.
    Not sure which one or both is necessary.
    Have your url be a trusted site, unblock it from popup blockage, and most of all stare at your formsweb.cfg default section. It would help
    if you specified what was in the url. do you have config=X in there?
    Edited by: lake on Jul 23, 2011 12:21 PM

  • How can I access instances from Interface Builder?

    Hello!
    How can I access instances build from the Interface Builder? For example, i know how to access Controller classes = just setting the class in the view identity. But I am missing some "connection" to my navigation controller. IB uses one, but in my code, i dont have one.
    All my xibs file owners have as their identity class a View or TableView Controller. But shouldnt they have a navigation controller as identy if the View or TableView is using a navigation Controller?
    thank you..

    thank you, .. i know.. the problem is, that i have different xib files, but i am not sure how i can connect them with their navigation controller / tabbarcontroller.
    it seems, that
    NSLog(@"pushing next view..");
    [[self navigationController] pushViewController:nextViewController animated:YES];
    is not enough. On the console, i can read pushing next view.. but it doesnt come up to the screen.

  • Instantiating a custom UITableViewCell from IB

    What is the recommended way to instantiate a custom UITableViewCell, or other object, created in IB that your app may need multiple instances of?
    My current approach is something along the following lines:
    NSArray *topLevelObjs = [[NSBundle mainBundle] loadNibNamed:@"CustomViewCell" owner:self options:nil];
    cell = [topLevelObjs objectAtIndex:1];
    This works, but doesn't seem particularly elegant. I tried implementing NSCopying for the custom class at one point but there doesn't seem to be any easy way to deep copy the class instance.
    Any suggestions?

    Digging through the apple example apps I found an example in "NavBar". An example of the relevant code:
    UIViewController *customViewController = [[CustomViewController alloc] initWithNibName:@"CustomViewController" bundle:nil];
    Message was edited by: dreyruugr

  • How to pass custom cookie from report builder application to SSRS Custom Security Extension?

    We want to implement SSRS in SaaS model. We implemented Custom Security extension in order to authenticate users from other application. When user enters username/password, i would like to authenticate the user in other application and it will return some data which can be used for autherization. I am expecting the same set of data will be accessible during all autherization calls.
    Currently we are implementing this in Report Builder application. I couldn't able to persist the information in cookie. Report builder removes all the cookies exceprt one cookie which is used by report server.Is there any way to share the information in all reportbuilder autherization calls in same session?

    if you have your own data extension, you can using
    HttpContext.Current.Application.Add("yourkey",
    yourdata);
    to save your data, but the issue I met it the key, I cannot find a key depended on report builder. If I use username, if the user open 2 report builder, both of them will get the same key and same data, but at this case the data should be different.
    I hope it will help you.

  • Importing a custom component from Flash Catalyst with Assets

    I am experimenting with Flash Catalyst to see if it would work well for us to create components for Flash Builder to use. As a test I created a very simple component with a Pie Chart and a button and exported it as a fxpl file. In Flash Builder I created a Flex library project and imported the component to it. When I tried to use the component in a trivial test app it gave me an error, saying 'Could not resolve <graphics:fc_pie> to a component implementation', presumably because it had not put the component files in the right place of the library tree - by default they were put in a folder at the same level as components but with the name of the component, below which it had a components folder and an assets folder. If I move the files in these folders to the corresponding folders under src then it works fine.
    The question is, how do I get Flash Builder to do this correctly? I assume I'm missing something obvious but I am a real Flash Builder Novice and this process is about evaluating which tools to use. Sorry if I'm being a numpty. I'm using Flash builder 4.5 and Flash Catalyst CS5.5.
    Any help much appreciated.

    If you look in the library panel, there should be an entry for your custom component - probably something like CustomComponent1.mxml. Drag this out onto the artboard to create a new instance of the component.
    In the case of a custom component, you can't change much on the second instance. If you have something like a text input skin though, you can change the text it is displaying for each instance.
    We are working on making this sort of thing easier in the future, so stay tuned

  • Customer service won't help with retaining email adresses!!!!

    I have spent hours and days on line with Verizon asking for help with a program they suggested I enroll in keepmyemail.com.   I have tried to purchase through website and ultimately get "user account is not eligible".  I have been routed through various departments for weeks with no resolution.  I was promised that by 1:30 today I would be able to sign up.  Well I cant and have been on the phone with multiple departments to find out why.  Last conversation I was told we have no idea why it wont work and I need to talk with the escalation  department.  Well so far I have been on hold for over an hour waiting to be transferred.  This is unacceptable!  By looking through the forums and on line this seems to be a popular issue with verizon.  Does anyone have advice or success in handling this issue?  I can't just cancel verizon as I need time to transition to another email provider. 
    I'm hoping I dont get hung up on like i have had done several times lately!!

    Hi handymanmac,
    Your issue has been escalated to a Verizon agent. Before the agent can begin assisting you, they will need to collect further information from you. Please go to your profile page for the forum and look at the top of the middle column where you will find an area titled "My Support Cases". You can reach your profile page by clicking on your name beside your post, or at the top left of this page underneath the title of the board.
    Under "My Support Cases" you will find a link to the private board where you and the agent may exchange information. The title of your post is the link. This should be checked on a frequent basis, as the agent may be waiting for information from you before they can proceed with any actions. To ensure you know when they have responded to you, at the top of your support case there is a drop down menu for support case options. Open that and choose "subscribe". Please keep all correspondence regarding your issue in the private support portal.

  • Export from Flash Builder with Error Message

    I was attempting to reduce my file size by removing the embedding. Got an error message when I tried to open it in Catalyst. "Flash Catalyst cannot open this project because it was created by an incompatible version of Flash Catalyst" Please help. Urgent.

    Hey Blink,
    Just to clarify, you completed the following steps:
    1) opened your Catalyst project in Flash Builder
    2) removed the 'embed' statements
    3) exported as an FXP
    4) Tried to re-open in Catalyst?
    We currently do not support a roundtrip workflow between Flash Catalyst and Flash Builder.
    Meaning once you open a Catalyst created project in Flash Builder, you can't bring it back to Catalyst for editing.
    We know this is really, really important to our users and it is on our list.
    Blink, let me know if this answers your question.  If the steps I listed are incorrect, and you did not in fact open your project in Builder, let me know.
    Are you using beta 1 or beta 2? Flash Catalyst 1.0, available today, contains a feature which allows you to toggle your images between 'embedded' and 'non-embedded'.  You can right click an image in the library panel to 'convert it to a linked image'.
    Thanks for posting!
    Tara

  • Can Not execute a TS Sequence File with VIs that are already being compile in my Custom TS Operator Interface

    I have build a custom TS Operator Interface (Executable) with some custom VI(s)(GOOP VIs). I want to be able to call the same custom VI(s) from Teststand Sequences. When i try ti launch the sequence from my TS OI i got an error message, because LabVIEW Run Time find the same VI(s) from two different location : the OI and the sequence.
    I would like to know, that is the best approach to resolve this problem.
    For the moment i got two solutions :
    (1) dynamically calling the VI(s) in the OI (executable)
    (2)Changing the name of the VIs in the TS sequence.
    I would like to know if it exist an another solution ?
    thank you
    derek

    For the moment the VI�s that are shared between the sequencefile�s and the operator interface, are used as code module in the sequencefile�s (not as sub vi in the code module).
    On the target system I will got my custom operator interface (which is build from the Testexec.llb + my goop VI�s). My goop VI�s are statically link to my operator interface.
    (I will say that my executable are on the C drive : C:\Testexec.exe)
    My sequencefile�s and the differents VI�s of each step is deploy with the TestStand deployment wizard. A library with all the vi�s call by the sequencefiles are group in SupportVIs.llb. (the sequencefiles and the VI�s library are on the C drive too)
    For exemple I will say that I got a foo.vi (goop
    method) which is build in the operator interface testexec.exe. The same foo.vi is call (as code module) by a step of one of my sequencefile�s.
    When I try to launch the sequence with the operator interface, The LabVIEW Run Time inform me that he can�t load step "foo" of sequence �MainSequence� because he find 2 VI�s with the same name in 2 different location (C:\Testexec.exe\foo.vi) and (C:\SupportVIs.llb\foo.vi.
    If you got a sample example, i will be glad to see it.
    Thank you Ray for your help.
    Derek

  • Web Interface Builder, error if use in Browser

    hallo,
    I can customizing in Web Interface Builder. But if I try to execute in the Browser (start Planning) than I become the following Logon error - Massage :
    Note
    The termination occurred in system XXX with error code 403 and for the reason Forbidden.
    The selected virtual host was 0 .
    How I can customizing that.
    Where I can create a user ID.
    Please can anybody give me step by step introductions.
    Please don't say that I have to refer to the admnistrator. I'm alone.
    I hope somebody help me.
    thanks

    HI,
    now it is result an other error.
    "Error when processing your request"
    Is this normal?
    I have activated the application (it was inactive before)
    In the TR ST22 is the text for error "CX_BSP_HOST_NOT_QUALIFIED"
    What that mean?.
    thanks.
    Message was edited by: oesi yol

  • Interface Builder and subclassing

    Is it possible for me to have the outlet in Interface Builder pointing to a superclass... then in the code using that interface to point to a subclass?
    So for example, suppose I'm setting up an interface in Interface Builder with a HumanView (let's say this is a subclass of UIView)... suppose this is like a character in an MMORPG... and you're customizing your chaacter...
    and correspondingly in my code I have:
    IBOutlet HumanView *character;
    But I'm uncertain whether this view will be a female or male character... In my code I have two subclass of HumanView... FemaleView and MaleView... each with its own unique instance variables and methods...
    Is it possible for me to decide in the program to have make "character" a FemaleView or MaleView?
    Thanks.
    Message was edited by: iphonemediaman

    Not a problem. I did realize I should add one minor clarification.
    1) You can cast a quadralateral to a square in one instance. When you know that actual object (the structure in memory) is a square.
    So, to be complete, you can safely cast a the square to a quadralateral all day long -- you know that a square is always a quadralateral. But if you are going to cast the quadralateral to a square, you should make sure you actually have a square object. The compiler will let you do it (might show a warning), but you could end up trying to reference pieces of a square that may not actually be part of the actual object. aka (in pseudo code):
    // no issues with these two alloc/inits
    Quad *foo = (Quad *)[[Square alloc] init];
    Quad *bar = (Quad *)[[Rectangle alloc] init];
    // both would return 4
    [foo numSides];
    [bar numSides];
    // if setSideLength is only a method on a Square, then
    // first line works fine
    [(Square*)foo setSideLength:20.0];
    // this line, however, will likely give a compiler warning and then
    // an EXC_BAD* error during runtime -- bar is not actually a square
    // in memory, despite what you are telling the compiler
    [(Square*)bar setSideLength:20.0];
    I hope I didn't conuse the issue -- but wanted to clarify.
    Cheers,
    George

  • Interface Builder - Picker + orientation

    Hi all,
    I just wanted to know if there is any way to add pickers to an application from Interface Builder, or do these have to be done programatically ?
    Also, is there any way to start a nib in interface builder that assumes / forces orientation into landscape when the application is started, as opposed to all applications being started as portrait ?
    Thanks...

    Thanks, but I'm still struggling to understand the interaction between Interface Builder and iPhone. I've built a xib that contains a UIView that I changed the class of to UIPickerView.
    After this, what do I need to do? Looking at the UIPickerView docs, it looks like I need to provide a delegate and a datasource.
    I can find examples of implementing the whole thing in code, but how do I do part of it in IB like I've done, and then provide the delegate and the datasource in the code ?
    I'm assuming that I need to associate an object / class with the Picker, but I'm not really sure I understand that at all.
    Are there any good starter docs out there for building an app in IB and then working with that in Xcode ?
    TIA,

  • Generate PDF from App. Srv. Produces Larger File than from Reports Builder

    Good Day,
    I have a the below issue , and need your help please.
    When generating a PDF report from the application server, the PDF size is large (200 MB) while
    same report is generated from the builder with smaller size 10MB.
    - Report Builder 9.0.2.0.3
    - The report contain only TEXT no Image , and contain arround 4000 pages ...
    The steps done from Application server in command line :
    - First I tested with several values for the parameter OUTPUTIMAGEFORMAT : file size stays the same or increases.
    - Second I tested with parameter PDFCOMP (for PDF compression) with varying values from 0 to 9 : file size stays the same.
    Kindly help ...

    From report builder :
    I open only the .rdf and generate the output to a PDF file.
    The number of page is from the PDf generated from Report builder , for the other one I Cant open it with PDF reader...
    Thx.
    MAN

Maybe you are looking for

  • Only 3 hours on battery doing nothing

    hi all. i am getting ready to take the 2009 MBP which I have had for a year and a half in to the genius bar and finally measured battery life at 3 hours doing absolutely nothing. This means I am down to about 2 or 2 1/2 hours when working on it. i ha

  • Anyone been able to install Flex Builder 2 on Vista?

    I am trying to figure out if there is a way to get Flex Builder 2 to install on Vista RTM yet. I can get Flex Builder 2.0 installed but when I try to perform the 2.0.1 update I get an error from the Install Anywhere application that I need to "select

  • Top Answerers Last 30 Days appears in IE but not Chrome?

    I observe that the Top Answerers Last 30 Days panel appears in Internet Explorer, but not in Chrome.  Could that be?  Anyone else able to reproduce this?

  • View Link sql window is non editable

    Hi All, I am creating view link between two views using wizard, but when I reach view link sql window it is blank and non editable. any ideas on this? Thanks in advance. Hitesh

  • Import pictures using SD adapter

    I have a SD card adapter & want to import pictures, but the photo app says no pictures available, but they are on the SD card.