Questions tagged [alloc]

207 questions
0
votes
1 answer

How to implement initWithCString:(const char *)nullTerminatedCString ? why most people use allocWithZone instead of alloc?

I have a doubt about the question of "How to implement initWithCString:(const char *)nullTerminatedCString". I search many answer of this question.Most of them use allocWithZone instead of alloc,but as i know, NSZone is abandoned by apple because of…
0
votes
2 answers

How to override and use alloc in Swift?

How to override object creation (alloc) and to add a custom logic? The reason is I always build my universal apps using 3 classes for each module (screen), for example 1. LoginViewController // this inherits from BaseViewController and holds…
Centurion
  • 14,106
  • 31
  • 105
  • 197
0
votes
2 answers

Why we need to alloc , init for a mutable object

I don't know if the question was asked previously and Im searching for some good answer. Question is : Whenever sometimes I don't use [[... alloc] init] for some mutable class , I get crash. Example : NSMutableDictionary *myDict = someObject ;…
Rajesh
  • 546
  • 9
  • 29
0
votes
1 answer

Tracking EXC_BAD_ACCESS on iPad

I've been using this code to create my UIWindow UIMyWindow* win = [[UIMyWindow alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; UIMyWindow isn't anything special it just has a pointer to a C++ class that does some…
Aleks
  • 1,177
  • 10
  • 21
0
votes
4 answers

How to debug anomalous C memory/stack problems

Sorry I can't be specific with code, but the problems I am seeing are anomalous. Character string values seem to be getting changed depending on other, unrelated code. For example, the value of the argument that is passed around below will change…
EBM
  • 1,683
  • 5
  • 15
  • 13
0
votes
2 answers

Newbie. Custom class

CustomClass *variableName = [[CustomClass alloc] init]; variableName.propertyName = @"Some text"; Could anyone explain this code step by step in human language? Why if I want to send data to a property in CustomClass I am accessing it throught…
Edgar
  • 898
  • 2
  • 12
  • 36
0
votes
1 answer

Object-c memory alloc IOS 7

I have a problem with memory full with RNDecryptor (+) in a cycle "for" i call this method es: for (int i=0; i < [datasource fileCount]; i++) { ... datacrypto = [RNDecryptor decryptData:datacrypto withSettings:kRNCryptorAES256Settings…
Marino
  • 1
  • 4
0
votes
0 answers

Logic Error: Argument in message expression is an uninitialized value

I am getting the Logic error when I analyzed my code. It is saying that "Argument in message expression is an uninitialized value" Here is what I have // allocate symbol int baseMatrixSize = compact ? 11 + layers * 4 : 14 + layers * 4; // not…
Teja Nandamuri
  • 11,045
  • 6
  • 57
  • 109
0
votes
1 answer

UIPickerView lost data after navigation

I am trying to implement an UIPickerView programmatically. I have implemented the delegate and datasource. When I first navigate to the UIPickerView everything works fine. If I leave the View and come back to it later, the UIPickerView looks…
BHuelse
  • 2,889
  • 3
  • 30
  • 41
0
votes
3 answers

Freeing array of struct

I've done some research and couldn't find any answer to my problem. I'm having problems with freeing my struct. This is how i create my struct: struct Structure * newStructure(int N) { struct Structure * structure; int i; structure =…
Patryk Krawczyk
  • 1,342
  • 1
  • 14
  • 25
0
votes
1 answer

C++ Dynamic Matrices Multiplying Return Issue

I'm trying to multiply to n**x**n dynamic matrices and returning it's result. This is the code for it: long long int** Multiply(long long int** m1, long long int **m2) { static long long int** output; output= new long long int* [k]; for…
BlastDV
  • 143
  • 5
0
votes
3 answers

Creating a singleton and overriding the alloc class method

I've created a singleton class using this code: static MyClass *sharedMyClass = nil; + (id)getInstance { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ sharedMyClass = [[self alloc] init]; }); return sharedMyClass; } my…
0
votes
2 answers

Finding the first occurance of a specific color - weird allocation behaviour

I am writing a function that returns the address of the first located pixel with specified color. Right now i am testing the detection. Currently on 50x50 bmp. Considering this code: dword bmp_find_xy (dword xp, dword yp) …
Edenia
  • 2,312
  • 1
  • 16
  • 33
0
votes
2 answers

Does alloc and init is create 2 instance of class?

I recently learn objective-c from Programming Objective C, 4th edition. I have question when reading to part: myFraction = [Fraction alloc]; myFraction = [myFraction init]; When you send the alloc message to a class, you get back a new instance of…
Steve Lam
  • 979
  • 1
  • 17
  • 40
0
votes
1 answer

How to replace a value of an integer in an NSMutableDictionary?

I have a time sensitive section of my code which stores, retrieves, and replaces values in an NSMutableDictionary. The problem is that I need to store objects, not primitives, and objects need to be allocated on the heap. However, once there exists…
Timothy Swan
  • 623
  • 3
  • 9
  • 21