Search Results

Search found 6745 results on 270 pages for 'objective c 2 0'.

Page 23/270 | < Previous Page | 19 20 21 22 23 24 25 26 27 28 29 30  | Next Page >

  • Objective-C global array of ints not working as expected

    - by Fran
    In my MyConstants.h file... I have: int abc[3]; In my matching MyConstants.m file... I have: extern int abc[3] = {11, 22, 33}; In each of my other *.m files... I have #import "MyConstants.h" Inside 1 of my viewDidLoad{} methods, I have: extern int abc[]; NSLog(@"abc = (%d) (%d)", abc[1], sizeof(abc)/sizeof(int)); Why does it display "abc = (0) (3)" instead of "abc = (22) (3)"? How do I make this work as expected?

    Read the article

  • Objective-C / C giving enums default values

    - by bandejapaisa
    I read somewhere about giving enums default values like so: typedef enum { MarketNavigationTypeNone = 0, MarketNavigationTypeHeirachy = 1, MarketNavigationTypeMarket = 2 } MarketNavigationLevelType; .. but i can't remember the value of doing this. If i don't give them default values - and then someone later on reorders the enum - what are the risks? If i always use the enum name and don't even refer to them by their integer value, is there any risks? The only possible problem i can think of is if i'm initialising an enum from an int value from a DB - and the enum is reordered - then the app would break.

    Read the article

  • Objective-c Method to get a number then countdown in 1 every second

    - by Sami
    Hi, i need a little help i have a method which gets value such as 50, it then assigns that value to trackDuration, so NSNumber *trackDuration = 50, i want the method to every second minus 1 from the value of trackDuration and update a label, the label being called duration. Here's what i have so far; - (void) countDown { iTunesApplication *iTunes = [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"]; NSNumber *trackDuration = [NSNumber numberWithDouble:[[iTunes currentTrack] duration]]; while (trackDuration > 0) { trackDuration - 1; int inputSeconds = [trackDuration intValue]; int hours = inputSeconds / 3600; int minutes = ( inputSeconds - hours * 3600 ) / 60; int seconds = inputSeconds - hours * 3600 - minutes * 60; NSString *trackDurationString = [NSString stringWithFormat:@"%.2d:%.2d:%.2d", hours, minutes, seconds]; [duration setStringValue:trackDurationString]; sleep(1); }} Any help would be much appreciated, thanks in advanced, Sami.

    Read the article

  • dealloc properties with assign and readwrite objective-c

    - by okami
    I have this structure: @interface MyList : NSObject { NSString* operation; NSString* link; } @property (readwrite) NSString* operation; @property (readwrite, assign) NSString* link; @end @implementation MyList @synthesize operation,link; @end I know that if I had retain instead of readwrite I should release the operation and link properties. BUT should I release the operation and link with the code above?

    Read the article

  • Objective-C retain counts in dealloc

    - by Michael Waterfall
    I'm seeing something fairly strange here, I've got breakpoints set in various dealloc methods in my app, and on inspection, the retain counts of the object self varies from 1 to 0. When dealloc is called, will the retain count of the object be set to 0 already? I'm using print (int) [self retainCount] in the console to test this. The 0's seem to only appear in the dealloc of my NSOperation's that are being run in an NSOperationQueue. Any idea why this is?

    Read the article

  • iPhone objective-c autoreleasing leaking

    - by okami
    I do this: NSString *fullpath = [[NSBundle mainBundle] pathForResource:@"text_file" ofType:@"txt"]; Why the following message appear? Is my code leaking? 2010-03-31 13:44:18.649 MJIPhone[2175:207] *** _NSAutoreleaseNoPool(): Object 0x3909ba0 of class NSPathStore2 autoreleased with no pool in place - just leaking Stack: (0x1656bf 0xc80d0 0xcf2ad 0xcee0e 0xd3327 0x2482 0x2426) 2010-03-31 13:44:18.653 MJIPhone[2175:207] *** _NSAutoreleaseNoPool(): Object 0x390b0b0 of class NSPathStore2 autoreleased with no pool in place - just leaking Stack: (0x1656bf 0xc80d0 0xc7159 0xd0c6f 0xd3421 0x2482 0x2426) 2010-03-31 13:44:18.672 MJIPhone[2175:207] *** _NSAutoreleaseNoPool(): Object 0x390d140 of class NSCFString autoreleased with no pool in place - just leaking Stack: (0x1656bf 0xc6e62 0xcec1b 0xd4386 0x24ac 0x2426)

    Read the article

  • Extract part of HTML in C/Objective-C

    - by Dan
    Hi, I need to extract the detail content of a website while preserve all formatting of the division. The section I wish to extract is: ... <div class="detailContent"><p> <P dir=ltr><STRONG>Hinweis</strong>: Auf ... </p> </div> ... My current solution is to use HTMLParser from libxml2 and xpath to find the nodes and walk through all the nodes to reconstruct this piece of HTML. This is a long an complicated code. I' just wondering if there is an easier solution to extract part of HTML? Thanks.

    Read the article

  • Array of pointers in Objective-C using NSArray

    - by Amir
    Hello, I am writting program for my iphone and have a qestion. lets say i have class named my_obj class my_obj { NSString *name; NSinteger *id; NSinteger *foo; NSString *boo; } now i allocate 100 objects from type my_obj and insert them to array from type NSArray. then i want to sort the Array in two different ways. one by the name and the second by the id. i want to allocate another two arrays from type NSArray *arraySortByName *arraySortById what i need to do if i just want the sorted arrays to be referenced to the original array so i will get two sorted arrays that point to the original array (that didnt changed!) i other word i dont want to allocate another 100 objects to each sorted array.

    Read the article

  • Objective-C subclasses question

    - by Johannes Jensen
    I have a class called Level, which is a subclass of NSObject. Then I have a class called Level_1_1 which is a subclass of Level. Is it allowed to type like Level* aLevel = [Level_1_1 alloc]; instead of Level_1_1* theLevel = [Level_1_1 alloc]; ? :) I try it and I don't get any warnings, just wondering if it's okay to do?

    Read the article

  • Using pointers to adjust global objects in objective-c

    - by Rob
    Ok, so I am working with two sets of data that are extremely similar, and at the same time, these data sets are both global NSMutableArrays within the object. data_set_one = [[NSMutableArray alloc] init]; data_set_two = [[NSMutableArray alloc] init]; Two new NSMutableArrays are loaded, which need to be added to the old, existing data. These Arrays are also global. xml_dataset_one = [[NSMutableArray alloc] init]; xml_dataset_two = [[NSMutableArray alloc] init]; To reduce code duplication (and because these data sets are so similar) I wrote a void method within the class to handle the data combination process for both Arrays: -(void)constructData:(NSMutableArray *)data fromDownloadArray:(NSMutableArray *)down withMatchSelector:(NSString *)sel_str Now, I have a decent understanding of object oriented programming, so I was thinking that if I were to invoke the method with the global Arrays in the data like so... [self constructData:data_set_one fromDownloadArray:xml_dataset_one withMatchSelector:@"id"]; Then the global NSMutableArrays (data_set_one) would reflect the changes that happen to "array" within the method. Sadly, this is not the case, data_set_one doesn't reflect the changes (ex: new objects within the Array) outside of the method. Here is a code snippet of the problem // data_set_one is empty // xml_dataset_one has a few objects [constructData:(NSMutableArray *)data_set_one fromDownloadArray:(NSMutableArray *)xml_dataset_one withMatchSelector:(NSString *)@"id"]; // data_set_one should now be xml_dataset_one, but when echoed to screen, it appears to remain empty And here is the gist of the code for the method, any help is appreciated. -(void)constructData:(NSMutableArray *)data fromDownloadArray:(NSMutableArray *)down withMatchSelector:(NSString *)sel_str { if ([data count] == 0) { data = down; // set data equal to downloaded data } else if ([down count] == 0) { // download yields no results, do nothing } else { // combine the two arrays here } } This project is not ARC enabled. Thanks for the help guys! Rob

    Read the article

  • objective c - release problem

    - by amir
    Hello, I have the following code: NSNumber *number = [NSNumber numberWithInt:5]; int i = [number retainCount]; [number release]; i = [number retainCount]; [number release]; i = [number retainCount]; the problem is that in line 2 , the value of parameter i is 2 and in line 4 the value is 1. then in line 6 the value is still 1.???????? first i dont understand why after init *number the retaincount is 2 and not 1?? second i dont understand why after release it 2 times retaincount is not 0? it doesnt matter how many times i release the object the retaincount stay 1.

    Read the article

  • How to solve the leaks when allocating the NSMutableArray in Objective-C

    - by Madan Mohan
    Hi Guys, I am getting leaks in Master view controller of iPhone. When I call this method, I am inserting them into filteredListCount array, because when I search I need to show the list from filteredListCount array otherwise customerArray. This functionality is working fine but I am getting leaks in the method below at allocation: filteredListCount = [[NSMutableArray alloc] initWithCapacity: [customerArray count]]; This is the first view controller of my application, I am showing the list and I am also allowing to search from a list. - (void)parser:(CustomerListLibXmlParser *)parser addCustomerObject:(Customer *)customerObj1 { [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; [customerArray addObject:customerObj1]; filteredListCount = [[NSMutableArray alloc] initWithCapacity: [customerArray count]]; [filteredListCount addObjectsFromArray: customerArray]; [theTableView reloadData]; } - (void)parser:(CustomerListLibXmlParser *)parser encounteredError:(NSError *)error { } - (void)parserFinished:(CustomerListLibXmlParser *)parser { [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; self.title=@"Customers"; }

    Read the article

  • Timer running while on home screen iPhone - Objective C

    - by Franky
    Hello, I am interested in building a Timer Based game such as mafia wars or soemthing like that. I'm stuck on one question. What would be the best way to retain a timer, even if the app is closed? Should I do this based on the Device Clock? or should I set a time to a server, and get the time when the device starts up? If any one knows a better way for this, let me know. Thanks. @lessfame

    Read the article

  • Objective-C: when does an assigned object get deallocated

    - by Stefan Klumpp
    If I have a instance method and within this method I do something like this: NSString *peopleString = [peopleList componentsJoinedByString: @", "]; ... UILabel *likeLabel = [[UILabel alloc] initWithFrame:CGRectMake(16.0+6.0f, 4.0f, 252.0f, 12.0f)]; [likeLabel setText:peopleString]; [likeLabel setFont:[UIFont fontWithName:@"Arial" size:12]]; [likeRow addSubview:likeLabel]; [likeLabel release]; The componentsJoinedByString doesn't contain a new, copy or alloc, thus I don't have to release it. What I'm wondering though is, when my peopleString gets deallocated. Might it happen to early? Meaning, before I can set the text in my label. Should I better use a [[NSString alloc] initWithString:[peopleList componentsJoinedByString: @", "]]; and release it at the end of this method?

    Read the article

  • Objective-c garbage collection

    - by Chris
    If garbage collection is not required: - (void) awakeFromNib{ //Create the NSStatusBar and set its length statusItem = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength] retain]; ... Do I have to release that? And if I do, would that be in a finalize method or dealloc method? If garbage collection is required, then is the retain call above ignored automatically?

    Read the article

  • Objective-c class initializer executes multiple times

    - by apisip
    Unless I misunderstood it, this LINK from Apple's documentation clearly states that the class initializer, "+ (void)initialize)", only executes once per class. Here is the excerpt: Special Considerations initialize it is invoked only once per class. If you want to perform independent initialization for the class and for categories of the class, you should implement load methods. However, I'm getting a weird behavior on my project and the initializer is being executed twice. So I have to check if _classContext is null. I only got one class that has this method. What are the possible reasons why this is happening? I'm using XCode 4.5.2 and OS X 10.8.2. I got multiple iOS simulators, iPhone 5.1 and 6.0. + (void) initialize { num++; NSLog([NSString stringWithFormat:@"Times: %i", num]); if(_classContext == nil) _classContext = [[myClass alloc] init]; }

    Read the article

  • NSTask Tail -f Using objective C

    - by Bach
    I need to read the last added line to a log file, in realtime, and capture that line being added. Something similar to Tail -f. So my first attempt was to use Tail -f using NSTask. I can't see any output using the code below: NSTask *server = [[NSTask alloc] init]; [server setLaunchPath:@"/usr/bin/tail"]; [server setArguments:[NSArray arrayWithObjects:@"-f", @"/path/to/my/LogFile.txt",nil]]; NSPipe *outputPipe = [NSPipe pipe]; [server setStandardInput:[NSPipe pipe]]; [server setStandardOutput:outputPipe]; [server launch]; [server waitUntilExit]; [server release]; NSData *outputData = [[outputPipe fileHandleForReading] readDataToEndOfFile]; NSString *outputString = [[[NSString alloc] initWithData:outputData encoding:NSUTF8StringEncoding] autorelease]; NSLog (@"Output \n%@", outputString); I can see the output as expected when using: [server setLaunchPath:@"/bin/ls"]; How can i capture the output of that tail NSTask? Is there any alternative to this method, where I can open a stream to file and each time a line is added, output it on screen? (basic logging functionality)

    Read the article

  • objective C convert NSString to unsigned

    - by user1501354
    I have changed my question. I want to convert an NSString to an unsigned int. Why? Because I want to do parallel payment in PayPal. Below I have given my coding in which I want to convert the NSString to an unsigned int. My query is: //optional, set shippingEnabled to TRUE if you want to display shipping //options to the user, default: TRUE [PayPal getPayPalInst].shippingEnabled = TRUE; //optional, set dynamicAmountUpdateEnabled to TRUE if you want to compute //shipping and tax based on the user's address choice, default: FALSE [PayPal getPayPalInst].dynamicAmountUpdateEnabled = TRUE; //optional, choose who pays the fee, default: FEEPAYER_EACHRECEIVER [PayPal getPayPalInst].feePayer = FEEPAYER_EACHRECEIVER; //for a payment with multiple recipients, use a PayPalAdvancedPayment object PayPalAdvancedPayment *payment = [[PayPalAdvancedPayment alloc] init]; payment.paymentCurrency = @"USD"; // A payment note applied to all recipients. payment.memo = @"A Note applied to all recipients"; //receiverPaymentDetails is a list of PPReceiverPaymentDetails objects payment.receiverPaymentDetails = [NSMutableArray array]; NSArray *emailArray = [NSArray arrayWithObjects:@"[email protected]",@"[email protected]", nil]; for (int i = 1; i <= 2; i++) { PayPalReceiverPaymentDetails *details = [[PayPalReceiverPaymentDetails alloc] init]; // Customize the payment notes for one of the three recipient. if (i == 2) { details.description = [NSString stringWithFormat:@"Component %d", i]; } details.recipient = [NSString stringWithFormat:@"%@",[emailArray objectAtIndex:i-1]]; unsigned order; if (i==1) { order = [[feeArray objectAtIndex:0] unsignedIntValue]; } if (i==2) { order = [[amountArray objectAtIndex:0] unsignedIntValue]; } //subtotal of all items for this recipient, without tax and shipping details.subTotal = [NSDecimalNumber decimalNumberWithMantissa:order exponent:-4 isNegative:FALSE]; //invoiceData is a PayPalInvoiceData object which contains tax, shipping, and a list of PayPalInvoiceItem objects details.invoiceData = [[PayPalInvoiceData alloc] init]; //invoiceItems is a list of PayPalInvoiceItem objects //NOTE: sum of totalPrice for all items must equal details.subTotal //NOTE: example only shows a single item, but you can have more than one details.invoiceData.invoiceItems = [NSMutableArray array]; PayPalInvoiceItem *item = [[PayPalInvoiceItem alloc] init]; item.totalPrice = details.subTotal; [details.invoiceData.invoiceItems addObject:item]; [payment.receiverPaymentDetails addObject:details]; } [[PayPal getPayPalInst] advancedCheckoutWithPayment:payment]; Can anybody tell me how to do this conversion? Thanks and regards in advance.

    Read the article

  • objective-c releasing uninitialized class members in dealloc method

    - by Dude Man
    Regarding over-releasing. Say I have a instance variable defined in Test.h NSString *mystring; In my implementation Test.m I do not initialize the variable mystring anywhere. But I release it in dealloc: -(void)dealloc { [mystring release]; } Is this now over-released? I've been doing the following in dealloc to avoid any issues, however, is this really necessary? -(void)dealloc { if (mystring) [mystring release]; } It seems that [nil release] shouldn't do anything, can someone verify this with class members?

    Read the article

< Previous Page | 19 20 21 22 23 24 25 26 27 28 29 30  | Next Page >