Questions tagged [alloc]
207 questions
1
vote
2 answers
alloc() error in swift
So I've just updated my swift to 2.0 and obviously a couple of errors appeared in my code.
Thats what I have right now.
unc loadRssFeed(data: NSURL) {
var myRssParser : ParserManager = ParserManager.alloc().initWithURL(data) as! ParserManager
…

Arsenii Nibble
- 59
- 2
- 8
1
vote
1 answer
Using move_alloc in a derived type
I have written a derived type that stores a multidimensional array. The array will be read from a file to an array b. I then want to transfer b to the derived type Space using member a. The advantage for mvalloc is not having to allocate two large…

Charles
- 145
- 2
- 10
1
vote
2 answers
why can't I use partial struct initialization for a malloced struct in C
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 heap like this.
struct sometype *a =…

Xeechem
- 35
- 1
- 6
1
vote
2 answers
Assistance with a Memory Allocation Error in c++, linux using g++
I've searched for others with similar problem's to mine, but they all have much different code than I.
When I compile the Following code with g++ I get the Error:
basketbOOP: malloc.c:2451: sYSMALLOc: Assertion `(old_top == (((mbinptr) (((char *)…

Craig
- 113
- 4
1
vote
3 answers
template style matrix implementation in c
From time to time I use the following code for generating a matrix style datastructure
typedef double myType;
typedef struct matrix_t{ |Compilation started at Mon Apr 5 02:24:15
myType…

monkeyking
- 6,670
- 24
- 61
- 81
1
vote
3 answers
Cocoa example - Why there is NO need to retain or release messages
I'm new to Objective-C and cocoa. In the guide provided by Apple for Cocoa, there is a confusing example in memory management:
Suppose you want to implement a method to reset the counter. You have a couple of choices. The first implementation…

Mohsen Mesgarpour
- 353
- 3
- 12
1
vote
4 answers
Why is alloc needed in Objective-C object initialization?
I have been going over some tutorials in Objective-C and I am confused when it comes to the command alloc() and how it is used to initialize an object.
The tutorial says to do the following and I am having trouble figuring out why it is…

webworm
- 10,587
- 33
- 120
- 217
1
vote
1 answer
Allocating memory of vector whose type is own Class C++
I've so far few posts about allocating memory for vectors
( Allocating memory for class in C++
Allocating memory for class in C++, for example)
but I didn't manage to find the solution for the problem I'm facing right now.
Let's go.. According to…

user1960582
- 21
- 1
- 3
1
vote
5 answers
Overriding init method to allocate memory for instance variable object
I am attempting to override the init method of a class so that initializing the object also initializes the ivar object:
-(id)init
{
if (self = [super init])
{
someIVarObject = [SomeClass alloc] init];
}
return self;
…

user2000809
- 496
- 2
- 13
1
vote
1 answer
Properly free memory alloc'd with enif_resource_alloc
I have written an Erlang C NIF that returns a pointer to a structure after calling new and for now just increments a variable on insert. I am wondering how to properly destroy the original resource, or at least mark it for GC. I am having no…

BAR
- 15,909
- 27
- 97
- 185
1
vote
1 answer
GKPeerPickerController throwing exception "expected expression"
I have written this little piece of code:
GKPeerPickerController *picker = [[GKPeerPickerController alloc] init];
but even after restarting my Mac XCode is telling me: "expected expression"!
Anyone having any idea solving this problem?
Thanks

user1710004
- 209
- 1
- 4
- 12
1
vote
1 answer
ObjC: using 'self' in init and/or initWithFrame:
I heard from someone that the state of a class is not yet stable inside -(id)init, so using 'self.something' is not recommended inside init, but I have a UIView subclass that need to add some subviews to itself when the class is created, so I have…

hzxu
- 5,753
- 11
- 60
- 95
1
vote
1 answer
Objects properties not reachable from all classes
I have 3 classes in my project : HeliController, FlightView and ConnectionView.
HeliController stores some connection data which is to be used by both FlightView and ConnectionView.
In both ConnectionView and HeliController I have
//…

chwi
- 2,752
- 2
- 41
- 66
1
vote
1 answer
Crash when I try to alloc a UIPopoverController
Hi I am at my wits end with what I am doing wrong here. Has anyone experienced anything similar? I checked the apple developer forums, google, stack overflow and couldn't find anything.
MyViewController *myView;
myView = [[MyViewController alloc]…

The Bird
- 397
- 2
- 8
- 19
1
vote
4 answers
Alloc a new objective C object to a retained property?
Sorry for asking a totally basic question, but if I have a synthesized property that is retained.
self.myProperty = [[NSObject alloc] init];
will cause a memory leak?
So am I correct in thinking that I need to do
self.myProperty = [[NSObject…

wfbarksdale
- 7,498
- 15
- 65
- 88