alloc Questions
6
Solved
I have the following code in Xcode :
NSError *error = [[NSError alloc] init];
NSData *urlData=[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
A...
8
Solved
I've just read about std::allocator. In my opinion, it is more complicated to use it instead of using new and delete.
With allocator we must explicitly allocate heap memory, construct it, destroy...
Backwoods asked 11/7, 2015 at 15:36
1
Solved
I use this program to store a mpz value but when I add a 0 (
400000000000000000000000000000000000000 instead of 40000000000000000000000000000000000000 -> 38 0s instead of 37) I get
free(): doub...
6
Solved
when I create a pointer to certain struct, do I have to set it to NULL, then alloc it then use it? and why?
7
Solved
Here is my TextValidator class:
//TextValidator.h
#import <Foundation/Foundation.h>
@interface TextValidator : NSObject
- (BOOL) isValidPassword:(NSString *)checkPassword;
- (BOOL) isValidE...
Yield asked 14/11, 2013 at 10:2
6
Solved
From forum discussion , seem like that the big difference is performance factor, allocWithZone: will alloc memory from particular memory area, which reduce cost of swapping.
In practice, almost g...
Dinsmore asked 23/12, 2010 at 2:2
7
Solved
Note: I'm relatively new to Objective-C and am coming from Java and PHP.
Could someone explain to me why I always have to first allocate and then initialize an instance?
Couldn't this be done in ...
Discobolus asked 6/9, 2009 at 11:11
5
Solved
Some small steps to begin wrapping my head around Swift. I've basically ported an old class that simply finds the matching icon for a name and return the appropriate UIImage. The Swift part of thin...
Nutpick asked 4/6, 2014 at 13:53
2
Solved
Apperently in C99 you can simply initialize a statically allocated struct in this way
struct sometype {
int a;
double b;
};
sometype a = {
.a = 0;
};
Well, this does not apply to a struct on ...
2
Solved
As far as I understand, in C++ you can create objects on the stack:
SomeClass object = SomeClass();
or on the heap:
SomeClass *object = new SomeClass();
In Objective-C you always seem to crea...
Arietta asked 18/12, 2013 at 16:29
2
Solved
BNRItemStore is a singleton, and I was confused on why super allocWithZone: must be called instead of plain old super alloc. And then override alloc instead of allocWithZone.
#import "BNRItemStore...
Glosseme asked 15/8, 2012 at 1:16
4
Solved
I've been searching but couldn't find an answer to this. Is there a way to tell the new operator to not call the class constructors?
MyObject* array = new MyObject[1000];
This will call MyObject...
Sunbonnet asked 1/5, 2013 at 10:16
2
Solved
To allocate memory in managed code i use:
IntPtr [] params_list_n = new IntPtr [5];
But for unmanaged memory i use Marshal.AllocHGlobal
And I do not understand how, in this case to allocate memo...
Abrade asked 24/3, 2013 at 22:33
3
Solved
Actually I am working on a project with ARC enabled. I know using alloc and init is taking ownership of the object. I know, If I create a string like this
NSString *myString = [[NSString alloc]ini...
Lazurite asked 21/11, 2012 at 14:31
4
Quick question... Well I understand that all properties start out as nil in Objective-C and that sending a message to nil does nothing, therefore you must initialize using [[Class alloc] init]; bef...
Histrionics asked 2/8, 2012 at 0:44
2
Solved
I'm getting this warning
"Automatic Reference Counting Issue: Assigning retained object to unsafe_unretained variable; object will be released after assignment"
Here is the code
.h
@interfac...
La asked 5/3, 2012 at 22:40
2
Solved
I'm trying to learn objective C and one of the things i find very weird to follow is when to use alloc and when not to. Take for instance this snip of code:
NSURL *url =[NSURL URLWithString:@"http...
Neck asked 6/11, 2011 at 14:1
2
Solved
I know that this is rarely required to override the alloc or dealloc methods,but if required is it possible in iPhone programming?
Egarton asked 29/9, 2011 at 11:28
4
Solved
In the following example, what are the possible problems that can occur.
id c = [Person alloc];
[c init];
Paganism asked 16/7, 2011 at 17:29
2
Solved
The StackOverflow question "using static keyword in objective-c when defining a cached variable" references code from Example 4 of Xcode's TableViewSuite that defines a static NSDateFormatter and c...
Impregnable asked 6/4, 2011 at 15:12
2
Solved
Since I had read realloc will act as malloc if the size pointed is 0, I was using it without malloc(), provided the pointer was static, global, or explicitly set to NULL if automatic.
However, I n...
Lashelllasher asked 16/12, 2010 at 9:40
1
© 2022 - 2024 — McMap. All rights reserved.