I have 5 views in my ASP.NET MVC application. Some data were captured from these views and I am navigating through these views using 2 buttons: the Previous and Next buttons.
So I fill the data in View 1 and I go to view 2 and enter the data there and so on.. till View 5.
Now the question is: If I come back again to previous views, ho...
Here's some code that has two arrays(np and op), one a copy of the other
However, when I modify the copy, the original is also modified!
take a look:
<script type="text/javascript">
var op=new Array(0, 0);
var np=op;
np[1]=2;
document.write(op+"<br>")
document.write(np)
</script>
Is there any way to retain the original and modify the...
I have a class derived from NSThread:
@interface FSEventMonitorThread : NSThread {
FSEventStreamRef m_fseStreamRef;
CFRunLoopRef m_runLoop;
}
- (id) initWithStream:
(FSEventStreamRef)fseStreamRef;
- (void) dealloc;
- (void) main;
@end
@implementation FSEventMonitorThread
- (id) initWithStream:
(FSEventStreamRef)fse...
Hi all,
I am creating instances of a class FlickrImage parsing a Flickr API photos response. The class has a method getLocation that does another API call to get the geolocation:
NSLog(@"getting location for %i",self.ID);
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
OFFlickrAPIRequest *flickrAPIRequest = [[OFFlickrAPIReq...
I am developing an iPhone application which is navigation based. Whenever the application quits, the retain count of the navigation controller and the window is 3. Can somebody explain me how to overcome this issue? The dealloc method, as a result, is not getting called.
...
I detach a thread to my method wich has a while-loop and even if I have an autoreleasePool, I release the objects manually since the while-loop can continue for a while...
The problem is that after a while, the app crashes due to memory problems and if I look in Instruments I can see a huge pile of NSString allocated and a stairway to he...
How would I code my android app to remember the values entered by the user between uses?
As an example, say I have an EditText "input1" and a spinner "input2" which give results in a textview named "output1".
Currently when I close and reopen the app, all entered values and calculations are lost and reset. How can I fix this?
...
Is there a way to retain values of textfield/textbox when a user submits a form? i only want to retain values with errors or values I specify.
For example i am posting to 10 blogs and 1-9 gets posted succesfully so I only want to retain the value from 10 when a page load after form submission. Can I do that? how?
...
Hello,
I am passing an object to a secondary thread using the following code:
(void)login:(id)sender
{
platformMsgs_LoginRequest *loginRequest = [[[platformMsgs_LoginRequest alloc] init] autorelease];
//more code...
[NSThread detachNewThreadSelector:@selector(sendLoginRequest:) toTarget:self withObject:loginRequest];
//more code......
I'm having trouble figuring out how to manage memory for an instance variable that needs to maintain it's current state for a period of time, then be reassigned to newly allocated memory.
Take the following example for the instance variable "importantData".:
-(void)Update
{
importantData = [[self getObject] retain];
}
- (SomeObjec...
Given the following code
@interface MyClass
{
SomeObject* o;
}
@property (nonatomic, retain) SomeObject* o;
@implementation MyClass
@synthesize o;
- (id)initWithSomeObject:(SomeObject*)s
{
if (self = [super init])
{
o = [s retain]; // WHAT DOES THIS DO? Double retain??
}
return self
}
@end
...
Can someone explain why the last line prints out -1? It happens when copy is called on a NSMutableString, I expect the returnCount of strFour to be 1, since an immutable copy should be returned.
NSMutableString *str =[NSMutableString stringWithString:@"hi"];
NSLog(@"new instantiated variable has a retain cout:");
NSLog(@"%d",[str re...
Hi,
I've seen a few posts on here about the issue of using retain or copy for strings. I still can't quite get my head around the difference or the importance.
In my case at the moment I have a class with a whole load of nsstrings to hold strings.
I want this class to only be instantiated once and I want its nsstring variables to chan...
i usually dont check the retain count untill the program leaks. But today (i donno y) i checked the retain count and now i am confused.
NSString *strErrorMessage;
strErrorMessage= [NSString stringWithFormat:@"Email and Password are mandatory"];
NSLog(@"%d", [strErrorMessage retainCount]); // retain count 1
[objAppD...
Whenever I push a view controller onto my stack, then pop it off, I get this error:
*** -[CALayer retainCount]: message sent to deallocated instance <memory address>
It seems to happen right after dealloc is called on the view controller that is being popped off and is exclusive to only this view controller. I'm sure the CALayer has s...
Let's say I do the following (foo starts out as some object):
[foo release];
// STUFF with foo
[foo retain];
As long as I'm not re-assigning foo, at the end of this I'll still have the same foo, right? I'm not risking losing foo during the //STUFF am I?
I guess I'm making sure that my understanding of release is correct. If I rel...
I have a tableView:didSelectRowAtIndexPath: where I create a ViewController-Instance each time an item is selected. Sometimes it works fine for a long time, sometimes it crashes with a EXC_BAD_ACCESS very quickly. The debugger blames the line [super dealloc]; in the QuestionDetailViewController.
Why? I log the QuestionDetailViewControll...
NSMutableArray count is returning zero after adding objects to it, its been an hour of hacking away trying to figure out why, and I'm still stuck, so that brings me here.
Any ideas based off the following code, what the problem is?
the object 'search' is a custom class defined in the header set as a pointer, with retain, nonatomic attr...
I init a navigation controller with:
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:firstViewController];
I wonder if the navigation controller retains firstViewController or that I need to keep it alive. When I release firstViewController, the navigation controller still works. That...
Hey everyone,
The more I code, the more I get lost ... so I decided to create a topic entirely dedicated to the memory management for me (and others) not to waste hours understanding obj-c basics ... I'll update it as new questions are asked !
Okay below is some examples :
// myArray is property (retain)
myArray = otherArray;
//myAr...