views:

213

answers:

4

Hi, I hope I don´t annoy you and you don´t have to answer this, but here is a little bit more explanation of my problem. I got all of the ids of the tweets with a NSArray. Then I set a NSNumber with:

NSNumber =[NSArray objectAtIndex:indexPath.row];

to get the right id of the tweet in the TableView row. Now I just wrote this:

 unsigned long fooo = NSNumber;
 NSLog("%@", fooo) // The right number
 [twitterEngine deleteUpdate:fooo];

But the finalURL has a other number. So for example fooo is: 8043688359, the finalUrl is this:

finalURL = https://twitter.com/statuses/destroy/62024352.xml

Also I get the HTTP error 403

All other methods like sendUpdate, getTimeline etc. are working. Just the deleteUpdate and the sendUpdate: inReplyTo aren´t working. I think it has something with a wrong number to do. Sorry for my bad English, bad I´m a young student from Germany and I´m just learning Objective-C (or programming generally) for three weeks.

The original methodes looking like that:

- (NSString *)sendUpdate:(NSString *)status inReplyTo:(unsigned long)updateID; // statuses/update

- (NSString *)deleteUpdate:(unsigned long)updateID; // statuses/destroy

Thanks!

A: 

Aproach it differently, as far as I can tell your code is something like:

NSNumber *aNumber = [anArray objectAtIndex:index.row]; unsigned long = aNumber;

In stead of using a unsigned long you should use a NSUinteger btw.

and doing it more directly: NSUInteger anInteger = [[anArray objectAtIndex:index.row] longValue]; // or longLongValue];

done. Tell me if I mis understood you.

Antwan van Houdt
Thanks for the answer, but it doens´t works. The App just crashes, when I use your code. Also the compiler says in the line: "assignment makes pointer from integer without a cast" and the console: [NSCFString longValue]: unrecognized selector sent to instance 0x3b78c50'
Flocked
well what kind of object is that? in the array, if it isn't a string than no it won't work, than something like unsignedIntValue could work, but this is really basic cocoa thing, look it up in the docs.
Antwan van Houdt
A: 

NSNumber is a class not an instance. The code could look something like the following:

NSNumber *myNumber = [NSArray objectAtIndex:indexPath.row];
unsigned long fooo = [NSNumber longValue];
NSLog("%l", fooo); // The right number
[twitterEngine deleteUpdate:fooo];

The return from -objectAtIndex: is an object and long is a primitive value. So you need to get the primitive long value out of the NSNumber object.

BTW, the odd number you are getting back is the memory address for the instance of the NSNumber.

Marcus S. Zarra
Thanks for the answer, but the app crashes and the console just writes: "[NSCFString longValue]: unrecognized selector sent to instance" when the program gets to the unsigned long fooo - line. Why?
Flocked
Then your object in the array is not an NSNumber! From the console output it is a string.
Marcus S. Zarra
+2  A: 

Got the answer: The MGTwitterEngine wants a unsigned long, but the iPhone is 32bit and so the the 64bit number gets smaller and MGTwitterEngine gets the wrong number. You have to edit the MGTwitterEngine. Just write unsigned long long in the methods.

Flocked
I don't understand why the id must be a number type anyway. It should be treated as a string IMO.
Ole Begemann
Yep, I realized that too - I just used a NSNumberformatter to get the number from the string.
Flocked
This is really odd, it seems like someone would have run into this issue before as MGTwitterEngine is widely used...
Kendall Helmstetter Gelner
A: 

Hi, I have the same issue. I change the methods to unsigned long long, but still my code is not working. Here is my code. I would appreciate any help.

myNumber = [tweets objectAtIndex:indexPath.row]; unsigned long fooo = [myNumber unsignedLongValue]; NSLog(@"fooo:%@", fooo); [_engine4 deleteUpdate:fooo];

Thanks