Note that there are some explanatory texts on larger screens.

plurals
  1. POXcode: Pass NSString from one class to another problem
    primarykey
    data
    text
    <p>OK this should be an easy one but still im breaking my head here:</p> <p>In my root view controller I have a <code>NSString</code> called "entry" and is working perfectly. I <code>NSLogged</code> it and it works. I have another class called ´ParseOperation´ and in it i have a <code>NSString</code>called "localEntry" and im trying to send to "ParseOperation" the variable "entry" from "RootViewController" this is my RootViewController code for that:</p> <pre><code>RootViewController.m ParseOperation *parseOperation = [[ParseOperation alloc] init]; parseOperation.localEntry = entry; </code></pre> <p>It just doesn't work. If I <code>NSLog</code> in my ParseOperation.m it returns "null", but if i do it on my RootViewController it returns the correct variable. and yes i did imported the ParseOperation.h</p> <p>Here is the ParseOperation code (only the part that uses localEntry):</p> <pre><code>ParseOperation.h @interface ParseOperation : NSOperation &lt;NSXMLParserDelegate&gt; { NSString *localEntry; } @property (nonatomic, retain) NSString *localEntry; @end ParseOperation.m @synthesize localEntry; - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict { //NSLog(@"entrada %@",localEntry); if ([elementName isEqualToString:localEntry]) { self.workingEntry = [[[AppRecord alloc] init] autorelease]; } storingCharacterData = [elementsToParse containsObject:elementName]; } - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName { if (self.workingEntry) { if (storingCharacterData) { NSString *trimmedString = [workingPropertyString stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]]; [workingPropertyString setString:@""]; // clear the string for next time if ([elementName isEqualToString:kIDStr]) { self.workingEntry.appURLString = trimmedString; } else if ([elementName isEqualToString:kNameStr]) { self.workingEntry.appName = trimmedString; } else if ([elementName isEqualToString:kImageStr]) { self.workingEntry.imageURLString = trimmedString; } else if ([elementName isEqualToString:kArtistStr]) { self.workingEntry.artist = trimmedString; } } else if ([elementName isEqualToString:localEntry]) { [self.workingArray addObject:self.workingEntry]; self.workingEntry = nil; } } } </code></pre> <p>THANKS!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload