I'm trying to consume an ASP.net Web service, and found a utility called WSDL2ObjC.
Now I'm trying to use it, and basic use is working (asking for simple data types, such as booleans or strings), but now I'm requesting an array of the "EmailServiceSvc_Email" structure, which contains "subject", "from" and "message" properties.
The app won't compile, with the message above, and here's the code on wich it gets stuck:
EmailServiceSvc_Email * eml = (EmailServiceSvc_Email *) arrEmails[[indexPath row]];
This is the explanation of the variables:
eml : the new variable I'm trying to get out of arrEmails.
arrEmails: an NSMutableArray of the EmailServiceSvc_Email object
indexPath: the indexPath parameter, this is from the cellForRowAtIndexPath function.
As you can see probably, I want to display all the "subject"s from the "EmailServiceSvc_Email" structure in a TableView, on the iPhone.
To get an element out of an NSMutableArray you must use -objectAtIndex:. The a[i] syntax does not work with NSArrays.
EmailServiceSvc_Email* eml = [arrEmails objectAtIndex:indexPath.row];
I wrote a tutorial about Wsdl2objc and complex types:
http://brismith66.blogspot.com/2010/07/iphone-development-accessing-soap.html
Related
I have a cell array. when I want create a cell array that its name is : '0691008752' in this case an error :"Invalid field name"
cellUsers.('0691008752') = ....
I know the reason for this error is that a number is called. But I do not know how I can set this name for the cell.
I agree with the comments above, prepending the field with a letter is the best solution for this problem..
One way to make this consistent is to use:
fname = matlab.lang.makeValidName('0691008752')
Its not widely known but you can have fields which begin with number - its bad practice and will almost certainly leads to bugs....
So how to do it, 1st you need to use mex, if you see the mathworks mex example and modify the appropriate line:
memcpy(fieldnames[0],"Doublestuff",sizeof("Doublestuff"));
to:
memcpy(fieldnames[0],"01234",sizeof("01234"));
After compiling and running you get:
Note: You can only access it through dynamic fields names. To update the field you must use mex.
In my app Web services are created in dot net and i am consuming those and I am getting response.In that all the fields like company,type,location everything are strings and there is no problem with this..And there is one more field called Exhibit number actually it is a Integer but they are created as string only.While I am displaying this it is showing zero instead of that number.. Here is my code...
//Storing into Array
[SurveyFilesArray addObject:[NSDictionary dictionaryWithObjectsAndKeys:[dic objectForKey:#"FileName"],#"FileName",[dic objectForKey:#"ExibhitNumber"],#"ExhibitNumber",[dic objectForKey:#"Description"],#"Description",[dic objectForKey:#"FileQuality"],#"FileQuality",nil]];
//Retrieving from Array..
NSLog(#"???%#???",[NSString stringWithFormat:#"%d",[[[SurveyFilesArray objectAtIndex:indexPath.row]objectForKey:#"ExibhitNumber"]intValue]]);
NSLog(#"%d",[[[SurveyFilesArray objectAtIndex:indexPath.row]objectForKey:#"ExibhitNumber"]intValue]);
You have typos in your code.
In the order of your code:
Ex-ib-hit-Number
Ex-hib-it-Number
These are 2 different strings.
In your example code you save it correctly written as Ex-hib-it. But you try to access it with ex-ib-hit afterwards. This cannot work.
I've combed the questions on here hoping to find a similar situation that I am in, but couldn't find one. My question deals with the NSJSONSerialization class in iOS 5, and how to handle parsing a single value returned from the JSONObjectWithData:options:error: method. The JSON data returned is a single value in an array that looks like this:
[1]
The data will either be 1 (as seen above) or 0, depending on the logic being done in the web service I'm using. As a side note, the web service is a WCF REST service. In XCode, the debugger displays the following after the deserialized JSON is assigned to a temporary NSArray object:
po parsedData
(NSArray *) $43 = 0x06e2ee70 <__NSCFArray 0x6e2ee70>( 1 )
When I try to get the value from the array using ObjectAtIndex:, I get this:
po [parsedData objectAtIndex:0]
(id) $44 = 0x06b1dad0 1
My question is: what is the hex value (0x06b1dad0) before the 1? Maybe a key or index that I am not accessing (I was thinking that I just didn't go far enough into the array to get the real value)? Does it have something to do with how the JSON is formatted? As I've been thinking about it, I have a feeling that the formatting is off.
The problem I am having is that I cannot get the actual value that is stored in the JSON message--when I access the element in the array parsedData and assign it to a variable, it is returning just the hex value and not 1.
Casting to NSInteger gives this:
po (NSInteger)[parsedData objectAtIndex:0]
(NSInteger) $45 = 112319184 1
Any insight into this would be greatly appreciated. I apologize if this has been addressed elsewhere in the forum.
Thanks.
Its likely that the object is an NSNumber try this:
[[parsedData objectAtIndex:0] intValue];
EDIT*
hi guys , lets say i have an array with 5 Strings = "1","2","3","4","5".
Im also doing parsing of xml. So how do i check whether a parse xml value is the same value of either one of the objects IN the array?
solved * i put them in a for loop to, looping through each array.value and making a root (if else) that checks whether the value in the array is equal to the parsed xml value
I'm not sure about parsing an xml with attributes. have seen a similar question here
But it shows to get an attribute of intValue. But i need to get the attributes of string type,How to do that?? Images of xml and the relevant portions are given in the following links
Click here for xml and here for required data
This answer to the linked question should work for you as well. The contents of attributeDict are already NStrings. All that is going on extra in the linked answer that they are calling the intValue method on the returned NSString to parse that string into an int. In your case, you don't need this little bit of an extra step. If you just do this:
NSString * stringValue = [attributeDict objectForKey:#"attribute"];
you'll have the value of the attribute called "attribute" in a string.