How To do json type Response?
I have one collection view in that I have to show images and video coming from backend I'm very new to do this I'm getting this response from backend.
SliderList = (
{
SliderID = 1;
SliderType = 1;
SliderURL = "http://mca.bananaappscenter.com/Images/SliderImages/MaskGroup2.png";
Status = 1;
},
{
SliderID = 2;
SliderType = 1;
SliderURL = "http://mca.bananaappscenter.com/Images/SliderImages/MaskGroup3.png";
Status = 1;
},
{
SliderID = 3;
SliderType = 2;
SliderURL = "https://www.youtube.com/watch?v=l1yN0KUHgoc";
Status = 1;
}
);
}
and I did like this
NSMutableDictionary *sampleDict = [ImagesArray objectAtIndex:indexPath.row];
NSString *imageStr = [[NSString alloc]init];
imageStr = [sampleDict valueForKey:@"SliderURL"];
if([imageStr isEqualToString:@"1"] || imageStr == nil)
{
cell.addImageView.image = [UIImage imageNamed:@""];
}
else
{
[cell.addImageView sd_setImageWithURL:[NSURL URLWithString:imageStr]
placeholderImage:[UIImage imageNamed:@"default"]];`
}
for above only images coming. if any Answer it would be appreciated. Thanks in Advance.
ios objective-c image video uicollectionview
|
show 7 more comments
I have one collection view in that I have to show images and video coming from backend I'm very new to do this I'm getting this response from backend.
SliderList = (
{
SliderID = 1;
SliderType = 1;
SliderURL = "http://mca.bananaappscenter.com/Images/SliderImages/MaskGroup2.png";
Status = 1;
},
{
SliderID = 2;
SliderType = 1;
SliderURL = "http://mca.bananaappscenter.com/Images/SliderImages/MaskGroup3.png";
Status = 1;
},
{
SliderID = 3;
SliderType = 2;
SliderURL = "https://www.youtube.com/watch?v=l1yN0KUHgoc";
Status = 1;
}
);
}
and I did like this
NSMutableDictionary *sampleDict = [ImagesArray objectAtIndex:indexPath.row];
NSString *imageStr = [[NSString alloc]init];
imageStr = [sampleDict valueForKey:@"SliderURL"];
if([imageStr isEqualToString:@"1"] || imageStr == nil)
{
cell.addImageView.image = [UIImage imageNamed:@""];
}
else
{
[cell.addImageView sd_setImageWithURL:[NSURL URLWithString:imageStr]
placeholderImage:[UIImage imageNamed:@"default"]];`
}
for above only images coming. if any Answer it would be appreciated. Thanks in Advance.
ios objective-c image video uicollectionview
plz add additional code
– Anbu.Karthik
Nov 21 '18 at 7:22
if(requestType == RequestTypeHomeSlider) { NSLog(@"%@",responseObject); NSString *respCode =[NSString stringWithFormat:@"%@", [responseDict valueForKey:@"StatusCode"]]; if([respCode isEqualToString:@"200"]) { ImagesArray= [NSMutableArray new]; ImagesArray = [responseObject valueForKey:@"SliderList"]; [_imageCollectionView reloadData]; }
– santoshi
Nov 21 '18 at 7:25
plz add additional code
– Anbu.Karthik
Nov 21 '18 at 7:26
Hi @karthik which code you want? please tell me
– santoshi
Nov 21 '18 at 7:27
related to your collectionview code or add entire class code in your question
– Anbu.Karthik
Nov 21 '18 at 7:28
|
show 7 more comments
I have one collection view in that I have to show images and video coming from backend I'm very new to do this I'm getting this response from backend.
SliderList = (
{
SliderID = 1;
SliderType = 1;
SliderURL = "http://mca.bananaappscenter.com/Images/SliderImages/MaskGroup2.png";
Status = 1;
},
{
SliderID = 2;
SliderType = 1;
SliderURL = "http://mca.bananaappscenter.com/Images/SliderImages/MaskGroup3.png";
Status = 1;
},
{
SliderID = 3;
SliderType = 2;
SliderURL = "https://www.youtube.com/watch?v=l1yN0KUHgoc";
Status = 1;
}
);
}
and I did like this
NSMutableDictionary *sampleDict = [ImagesArray objectAtIndex:indexPath.row];
NSString *imageStr = [[NSString alloc]init];
imageStr = [sampleDict valueForKey:@"SliderURL"];
if([imageStr isEqualToString:@"1"] || imageStr == nil)
{
cell.addImageView.image = [UIImage imageNamed:@""];
}
else
{
[cell.addImageView sd_setImageWithURL:[NSURL URLWithString:imageStr]
placeholderImage:[UIImage imageNamed:@"default"]];`
}
for above only images coming. if any Answer it would be appreciated. Thanks in Advance.
ios objective-c image video uicollectionview
I have one collection view in that I have to show images and video coming from backend I'm very new to do this I'm getting this response from backend.
SliderList = (
{
SliderID = 1;
SliderType = 1;
SliderURL = "http://mca.bananaappscenter.com/Images/SliderImages/MaskGroup2.png";
Status = 1;
},
{
SliderID = 2;
SliderType = 1;
SliderURL = "http://mca.bananaappscenter.com/Images/SliderImages/MaskGroup3.png";
Status = 1;
},
{
SliderID = 3;
SliderType = 2;
SliderURL = "https://www.youtube.com/watch?v=l1yN0KUHgoc";
Status = 1;
}
);
}
and I did like this
NSMutableDictionary *sampleDict = [ImagesArray objectAtIndex:indexPath.row];
NSString *imageStr = [[NSString alloc]init];
imageStr = [sampleDict valueForKey:@"SliderURL"];
if([imageStr isEqualToString:@"1"] || imageStr == nil)
{
cell.addImageView.image = [UIImage imageNamed:@""];
}
else
{
[cell.addImageView sd_setImageWithURL:[NSURL URLWithString:imageStr]
placeholderImage:[UIImage imageNamed:@"default"]];`
}
for above only images coming. if any Answer it would be appreciated. Thanks in Advance.
ios objective-c image video uicollectionview
ios objective-c image video uicollectionview
edited Nov 21 '18 at 7:21
Anbu.Karthik
61.5k16121111
61.5k16121111
asked Nov 21 '18 at 7:19
santoshisantoshi
324113
324113
plz add additional code
– Anbu.Karthik
Nov 21 '18 at 7:22
if(requestType == RequestTypeHomeSlider) { NSLog(@"%@",responseObject); NSString *respCode =[NSString stringWithFormat:@"%@", [responseDict valueForKey:@"StatusCode"]]; if([respCode isEqualToString:@"200"]) { ImagesArray= [NSMutableArray new]; ImagesArray = [responseObject valueForKey:@"SliderList"]; [_imageCollectionView reloadData]; }
– santoshi
Nov 21 '18 at 7:25
plz add additional code
– Anbu.Karthik
Nov 21 '18 at 7:26
Hi @karthik which code you want? please tell me
– santoshi
Nov 21 '18 at 7:27
related to your collectionview code or add entire class code in your question
– Anbu.Karthik
Nov 21 '18 at 7:28
|
show 7 more comments
plz add additional code
– Anbu.Karthik
Nov 21 '18 at 7:22
if(requestType == RequestTypeHomeSlider) { NSLog(@"%@",responseObject); NSString *respCode =[NSString stringWithFormat:@"%@", [responseDict valueForKey:@"StatusCode"]]; if([respCode isEqualToString:@"200"]) { ImagesArray= [NSMutableArray new]; ImagesArray = [responseObject valueForKey:@"SliderList"]; [_imageCollectionView reloadData]; }
– santoshi
Nov 21 '18 at 7:25
plz add additional code
– Anbu.Karthik
Nov 21 '18 at 7:26
Hi @karthik which code you want? please tell me
– santoshi
Nov 21 '18 at 7:27
related to your collectionview code or add entire class code in your question
– Anbu.Karthik
Nov 21 '18 at 7:28
plz add additional code
– Anbu.Karthik
Nov 21 '18 at 7:22
plz add additional code
– Anbu.Karthik
Nov 21 '18 at 7:22
if(requestType == RequestTypeHomeSlider) { NSLog(@"%@",responseObject); NSString *respCode =[NSString stringWithFormat:@"%@", [responseDict valueForKey:@"StatusCode"]]; if([respCode isEqualToString:@"200"]) { ImagesArray= [NSMutableArray new]; ImagesArray = [responseObject valueForKey:@"SliderList"]; [_imageCollectionView reloadData]; }
– santoshi
Nov 21 '18 at 7:25
if(requestType == RequestTypeHomeSlider) { NSLog(@"%@",responseObject); NSString *respCode =[NSString stringWithFormat:@"%@", [responseDict valueForKey:@"StatusCode"]]; if([respCode isEqualToString:@"200"]) { ImagesArray= [NSMutableArray new]; ImagesArray = [responseObject valueForKey:@"SliderList"]; [_imageCollectionView reloadData]; }
– santoshi
Nov 21 '18 at 7:25
plz add additional code
– Anbu.Karthik
Nov 21 '18 at 7:26
plz add additional code
– Anbu.Karthik
Nov 21 '18 at 7:26
Hi @karthik which code you want? please tell me
– santoshi
Nov 21 '18 at 7:27
Hi @karthik which code you want? please tell me
– santoshi
Nov 21 '18 at 7:27
related to your collectionview code or add entire class code in your question
– Anbu.Karthik
Nov 21 '18 at 7:28
related to your collectionview code or add entire class code in your question
– Anbu.Karthik
Nov 21 '18 at 7:28
|
show 7 more comments
3 Answers
3
active
oldest
votes
I got Answer for my question thank you every one who responded to me
if ([ImagesArray[indexPath.row][@"SliderType"] intValue]==1) {
NSString *imageStr=ImagesArray[indexPath.row][@"SliderURL"];
[cell.addImageView sd_setImageWithURL:[NSURL URLWithString:imageStr]
placeholderImage:[UIImage imageNamed:@"default"]];
}else if ([ImagesArray[indexPath.row][@"SliderType"] intValue]==2) {
NSString *imageStr=ImagesArray[indexPath.row][@"SliderURL"];
[cell.addImageView sd_setImageWithURL:[NSURL URLWithString:imageStr]
placeholderImage:[UIImage imageNamed:@"VideoButton"]];
}
add a comment |
As I understand from question and your extended discussion on chat you are facing trouble with showing video in cell along with Images. In order to show video along with image you will need to use a different approach.
- First thing you need to do is to find if this is video URL or image. Best way to do that will be to segregate that by adding a parameter in your web-service which indicate if this is a image or video.
- Once that is out of system you will need a special view that can load video perfectly i have used this library and it works fine.
- Now in your cell add both
imageView
and video player view, and add a condition where you check if it's video then displayYTPlayerView
or imageView based on returned information.
Then with help pf these function you can load video on your player View:
+ (NSString *)extractYoutubeIdFromLink:(NSString *)link {
if (link == nil) nil;
NSString *regexString = @"((?<=(v|V)/)|(?<=be/)|(?<=(\?|\&)v=)|(?<=embed/))([\w-]++)";
NSRegularExpression *regExp = [NSRegularExpression regularExpressionWithPattern:regexString
options:NSRegularExpressionCaseInsensitive
error:nil];
NSArray *array = [regExp matchesInString:link options:0 range:NSMakeRange(0,link.length)];
if (array.count > 0) {
NSTextCheckingResult *result = array.firstObject;
return [link substringWithRange:result.range];
}
return nil;
}
//Write this line on your function where you want to load video
[_videoView loadWithVideoId:[SCUtility extractYoutubeIdFromLink:_videoURL]];
add a comment |
I have added code in swift lang .. You can take reference and apply same logic there. It will work
let ImagesArray = [
[
"SliderID" : 1,
"SliderType" : 1,
"SliderURL" : "http://mca.bananaappscenter.com/Images/SliderImages/MaskGroup2.png",
"Status" : 1
],
[
"SliderID" : 2,
"SliderType" : 1,
"SliderURL" : "http://mca.bananaappscenter.com/Images/SliderImages/MaskGroup3.png",
"Status" : 1
],
[
"SliderID" : 3,
"SliderType" : 2,
"SliderURL" : "https://www.youtube.com/watch?v=l1yN0KUHgoc",
"Status" : 1
]
]
In tableview cellforrow u can implement like this :
let sampleDict = ImagesArray[indexPath.row] as? NSDictionary
let SliderURL = sampleDict.valueForkey("SliderURL") as? String
let SliderType = sampleDict.objectForkey("SliderType") as? NSNumber
if SliderURL != nil{
//means url abvl
if SliderType == 2{
//video data
cell.addImageView.image = "set video default thumbnail image "
}else if SliderType == 1{
//imagedata
// cell.addImageView.image = "set ur image "
}
}
In Objective C
NSMutableDictionary *sampleDict = [ImagesArray objectAtIndex:indexPath.row];
NSString *imageStr = [[NSString alloc]init];
imageStr = [sampleDict valueForKey:@"SliderURL"];
// NSString * SliderType = [[NSString alloc]init];
// SliderType = [sampleDict valueForKey:@"SliderType"];
int SliderType = [[sampleDict valueForKey:@"SliderType"] integerValue];
NSLog(@"%i", SliderType);
if(imageStr != nil)
{
//if([SliderType isEqualToString:@"2"]
if [SliderType isEqualToNumber:[NSNumber numberWithInt:2]] {
cell.addImageView.image = [UIImage imageNamed:@"default"];
}else if [SliderType isEqualToNumber:[NSNumber numberWithInt:1]] {
[cell.addImageView sd_setImageWithURL:[NSURL URLWithString:imageStr]
placeholderImage:[UIImage imageNamed:@"default"]];`
}else{
//nothng
}
}
else
{
//SliderURL is nil
}
can you please update in objective c
– santoshi
Nov 21 '18 at 9:47
code edited apply it .. @santoshi
– PRADIP KUMAR
Nov 21 '18 at 9:57
error coming invalid argument NCSFNUMBEr
– santoshi
Nov 21 '18 at 10:37
your SliderType data is of number type.. first fetch in number/Int type
– PRADIP KUMAR
Nov 21 '18 at 11:17
int SliderType = [sampleDict[@"SliderType"] integerValue];
– PRADIP KUMAR
Nov 21 '18 at 11:20
|
show 1 more comment
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53407029%2fhow-to-do-json-type-response%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
I got Answer for my question thank you every one who responded to me
if ([ImagesArray[indexPath.row][@"SliderType"] intValue]==1) {
NSString *imageStr=ImagesArray[indexPath.row][@"SliderURL"];
[cell.addImageView sd_setImageWithURL:[NSURL URLWithString:imageStr]
placeholderImage:[UIImage imageNamed:@"default"]];
}else if ([ImagesArray[indexPath.row][@"SliderType"] intValue]==2) {
NSString *imageStr=ImagesArray[indexPath.row][@"SliderURL"];
[cell.addImageView sd_setImageWithURL:[NSURL URLWithString:imageStr]
placeholderImage:[UIImage imageNamed:@"VideoButton"]];
}
add a comment |
I got Answer for my question thank you every one who responded to me
if ([ImagesArray[indexPath.row][@"SliderType"] intValue]==1) {
NSString *imageStr=ImagesArray[indexPath.row][@"SliderURL"];
[cell.addImageView sd_setImageWithURL:[NSURL URLWithString:imageStr]
placeholderImage:[UIImage imageNamed:@"default"]];
}else if ([ImagesArray[indexPath.row][@"SliderType"] intValue]==2) {
NSString *imageStr=ImagesArray[indexPath.row][@"SliderURL"];
[cell.addImageView sd_setImageWithURL:[NSURL URLWithString:imageStr]
placeholderImage:[UIImage imageNamed:@"VideoButton"]];
}
add a comment |
I got Answer for my question thank you every one who responded to me
if ([ImagesArray[indexPath.row][@"SliderType"] intValue]==1) {
NSString *imageStr=ImagesArray[indexPath.row][@"SliderURL"];
[cell.addImageView sd_setImageWithURL:[NSURL URLWithString:imageStr]
placeholderImage:[UIImage imageNamed:@"default"]];
}else if ([ImagesArray[indexPath.row][@"SliderType"] intValue]==2) {
NSString *imageStr=ImagesArray[indexPath.row][@"SliderURL"];
[cell.addImageView sd_setImageWithURL:[NSURL URLWithString:imageStr]
placeholderImage:[UIImage imageNamed:@"VideoButton"]];
}
I got Answer for my question thank you every one who responded to me
if ([ImagesArray[indexPath.row][@"SliderType"] intValue]==1) {
NSString *imageStr=ImagesArray[indexPath.row][@"SliderURL"];
[cell.addImageView sd_setImageWithURL:[NSURL URLWithString:imageStr]
placeholderImage:[UIImage imageNamed:@"default"]];
}else if ([ImagesArray[indexPath.row][@"SliderType"] intValue]==2) {
NSString *imageStr=ImagesArray[indexPath.row][@"SliderURL"];
[cell.addImageView sd_setImageWithURL:[NSURL URLWithString:imageStr]
placeholderImage:[UIImage imageNamed:@"VideoButton"]];
}
answered Nov 21 '18 at 12:34
santoshisantoshi
324113
324113
add a comment |
add a comment |
As I understand from question and your extended discussion on chat you are facing trouble with showing video in cell along with Images. In order to show video along with image you will need to use a different approach.
- First thing you need to do is to find if this is video URL or image. Best way to do that will be to segregate that by adding a parameter in your web-service which indicate if this is a image or video.
- Once that is out of system you will need a special view that can load video perfectly i have used this library and it works fine.
- Now in your cell add both
imageView
and video player view, and add a condition where you check if it's video then displayYTPlayerView
or imageView based on returned information.
Then with help pf these function you can load video on your player View:
+ (NSString *)extractYoutubeIdFromLink:(NSString *)link {
if (link == nil) nil;
NSString *regexString = @"((?<=(v|V)/)|(?<=be/)|(?<=(\?|\&)v=)|(?<=embed/))([\w-]++)";
NSRegularExpression *regExp = [NSRegularExpression regularExpressionWithPattern:regexString
options:NSRegularExpressionCaseInsensitive
error:nil];
NSArray *array = [regExp matchesInString:link options:0 range:NSMakeRange(0,link.length)];
if (array.count > 0) {
NSTextCheckingResult *result = array.firstObject;
return [link substringWithRange:result.range];
}
return nil;
}
//Write this line on your function where you want to load video
[_videoView loadWithVideoId:[SCUtility extractYoutubeIdFromLink:_videoURL]];
add a comment |
As I understand from question and your extended discussion on chat you are facing trouble with showing video in cell along with Images. In order to show video along with image you will need to use a different approach.
- First thing you need to do is to find if this is video URL or image. Best way to do that will be to segregate that by adding a parameter in your web-service which indicate if this is a image or video.
- Once that is out of system you will need a special view that can load video perfectly i have used this library and it works fine.
- Now in your cell add both
imageView
and video player view, and add a condition where you check if it's video then displayYTPlayerView
or imageView based on returned information.
Then with help pf these function you can load video on your player View:
+ (NSString *)extractYoutubeIdFromLink:(NSString *)link {
if (link == nil) nil;
NSString *regexString = @"((?<=(v|V)/)|(?<=be/)|(?<=(\?|\&)v=)|(?<=embed/))([\w-]++)";
NSRegularExpression *regExp = [NSRegularExpression regularExpressionWithPattern:regexString
options:NSRegularExpressionCaseInsensitive
error:nil];
NSArray *array = [regExp matchesInString:link options:0 range:NSMakeRange(0,link.length)];
if (array.count > 0) {
NSTextCheckingResult *result = array.firstObject;
return [link substringWithRange:result.range];
}
return nil;
}
//Write this line on your function where you want to load video
[_videoView loadWithVideoId:[SCUtility extractYoutubeIdFromLink:_videoURL]];
add a comment |
As I understand from question and your extended discussion on chat you are facing trouble with showing video in cell along with Images. In order to show video along with image you will need to use a different approach.
- First thing you need to do is to find if this is video URL or image. Best way to do that will be to segregate that by adding a parameter in your web-service which indicate if this is a image or video.
- Once that is out of system you will need a special view that can load video perfectly i have used this library and it works fine.
- Now in your cell add both
imageView
and video player view, and add a condition where you check if it's video then displayYTPlayerView
or imageView based on returned information.
Then with help pf these function you can load video on your player View:
+ (NSString *)extractYoutubeIdFromLink:(NSString *)link {
if (link == nil) nil;
NSString *regexString = @"((?<=(v|V)/)|(?<=be/)|(?<=(\?|\&)v=)|(?<=embed/))([\w-]++)";
NSRegularExpression *regExp = [NSRegularExpression regularExpressionWithPattern:regexString
options:NSRegularExpressionCaseInsensitive
error:nil];
NSArray *array = [regExp matchesInString:link options:0 range:NSMakeRange(0,link.length)];
if (array.count > 0) {
NSTextCheckingResult *result = array.firstObject;
return [link substringWithRange:result.range];
}
return nil;
}
//Write this line on your function where you want to load video
[_videoView loadWithVideoId:[SCUtility extractYoutubeIdFromLink:_videoURL]];
As I understand from question and your extended discussion on chat you are facing trouble with showing video in cell along with Images. In order to show video along with image you will need to use a different approach.
- First thing you need to do is to find if this is video URL or image. Best way to do that will be to segregate that by adding a parameter in your web-service which indicate if this is a image or video.
- Once that is out of system you will need a special view that can load video perfectly i have used this library and it works fine.
- Now in your cell add both
imageView
and video player view, and add a condition where you check if it's video then displayYTPlayerView
or imageView based on returned information.
Then with help pf these function you can load video on your player View:
+ (NSString *)extractYoutubeIdFromLink:(NSString *)link {
if (link == nil) nil;
NSString *regexString = @"((?<=(v|V)/)|(?<=be/)|(?<=(\?|\&)v=)|(?<=embed/))([\w-]++)";
NSRegularExpression *regExp = [NSRegularExpression regularExpressionWithPattern:regexString
options:NSRegularExpressionCaseInsensitive
error:nil];
NSArray *array = [regExp matchesInString:link options:0 range:NSMakeRange(0,link.length)];
if (array.count > 0) {
NSTextCheckingResult *result = array.firstObject;
return [link substringWithRange:result.range];
}
return nil;
}
//Write this line on your function where you want to load video
[_videoView loadWithVideoId:[SCUtility extractYoutubeIdFromLink:_videoURL]];
answered Nov 21 '18 at 8:01
rptwsthirptwsthi
8,56885392
8,56885392
add a comment |
add a comment |
I have added code in swift lang .. You can take reference and apply same logic there. It will work
let ImagesArray = [
[
"SliderID" : 1,
"SliderType" : 1,
"SliderURL" : "http://mca.bananaappscenter.com/Images/SliderImages/MaskGroup2.png",
"Status" : 1
],
[
"SliderID" : 2,
"SliderType" : 1,
"SliderURL" : "http://mca.bananaappscenter.com/Images/SliderImages/MaskGroup3.png",
"Status" : 1
],
[
"SliderID" : 3,
"SliderType" : 2,
"SliderURL" : "https://www.youtube.com/watch?v=l1yN0KUHgoc",
"Status" : 1
]
]
In tableview cellforrow u can implement like this :
let sampleDict = ImagesArray[indexPath.row] as? NSDictionary
let SliderURL = sampleDict.valueForkey("SliderURL") as? String
let SliderType = sampleDict.objectForkey("SliderType") as? NSNumber
if SliderURL != nil{
//means url abvl
if SliderType == 2{
//video data
cell.addImageView.image = "set video default thumbnail image "
}else if SliderType == 1{
//imagedata
// cell.addImageView.image = "set ur image "
}
}
In Objective C
NSMutableDictionary *sampleDict = [ImagesArray objectAtIndex:indexPath.row];
NSString *imageStr = [[NSString alloc]init];
imageStr = [sampleDict valueForKey:@"SliderURL"];
// NSString * SliderType = [[NSString alloc]init];
// SliderType = [sampleDict valueForKey:@"SliderType"];
int SliderType = [[sampleDict valueForKey:@"SliderType"] integerValue];
NSLog(@"%i", SliderType);
if(imageStr != nil)
{
//if([SliderType isEqualToString:@"2"]
if [SliderType isEqualToNumber:[NSNumber numberWithInt:2]] {
cell.addImageView.image = [UIImage imageNamed:@"default"];
}else if [SliderType isEqualToNumber:[NSNumber numberWithInt:1]] {
[cell.addImageView sd_setImageWithURL:[NSURL URLWithString:imageStr]
placeholderImage:[UIImage imageNamed:@"default"]];`
}else{
//nothng
}
}
else
{
//SliderURL is nil
}
can you please update in objective c
– santoshi
Nov 21 '18 at 9:47
code edited apply it .. @santoshi
– PRADIP KUMAR
Nov 21 '18 at 9:57
error coming invalid argument NCSFNUMBEr
– santoshi
Nov 21 '18 at 10:37
your SliderType data is of number type.. first fetch in number/Int type
– PRADIP KUMAR
Nov 21 '18 at 11:17
int SliderType = [sampleDict[@"SliderType"] integerValue];
– PRADIP KUMAR
Nov 21 '18 at 11:20
|
show 1 more comment
I have added code in swift lang .. You can take reference and apply same logic there. It will work
let ImagesArray = [
[
"SliderID" : 1,
"SliderType" : 1,
"SliderURL" : "http://mca.bananaappscenter.com/Images/SliderImages/MaskGroup2.png",
"Status" : 1
],
[
"SliderID" : 2,
"SliderType" : 1,
"SliderURL" : "http://mca.bananaappscenter.com/Images/SliderImages/MaskGroup3.png",
"Status" : 1
],
[
"SliderID" : 3,
"SliderType" : 2,
"SliderURL" : "https://www.youtube.com/watch?v=l1yN0KUHgoc",
"Status" : 1
]
]
In tableview cellforrow u can implement like this :
let sampleDict = ImagesArray[indexPath.row] as? NSDictionary
let SliderURL = sampleDict.valueForkey("SliderURL") as? String
let SliderType = sampleDict.objectForkey("SliderType") as? NSNumber
if SliderURL != nil{
//means url abvl
if SliderType == 2{
//video data
cell.addImageView.image = "set video default thumbnail image "
}else if SliderType == 1{
//imagedata
// cell.addImageView.image = "set ur image "
}
}
In Objective C
NSMutableDictionary *sampleDict = [ImagesArray objectAtIndex:indexPath.row];
NSString *imageStr = [[NSString alloc]init];
imageStr = [sampleDict valueForKey:@"SliderURL"];
// NSString * SliderType = [[NSString alloc]init];
// SliderType = [sampleDict valueForKey:@"SliderType"];
int SliderType = [[sampleDict valueForKey:@"SliderType"] integerValue];
NSLog(@"%i", SliderType);
if(imageStr != nil)
{
//if([SliderType isEqualToString:@"2"]
if [SliderType isEqualToNumber:[NSNumber numberWithInt:2]] {
cell.addImageView.image = [UIImage imageNamed:@"default"];
}else if [SliderType isEqualToNumber:[NSNumber numberWithInt:1]] {
[cell.addImageView sd_setImageWithURL:[NSURL URLWithString:imageStr]
placeholderImage:[UIImage imageNamed:@"default"]];`
}else{
//nothng
}
}
else
{
//SliderURL is nil
}
can you please update in objective c
– santoshi
Nov 21 '18 at 9:47
code edited apply it .. @santoshi
– PRADIP KUMAR
Nov 21 '18 at 9:57
error coming invalid argument NCSFNUMBEr
– santoshi
Nov 21 '18 at 10:37
your SliderType data is of number type.. first fetch in number/Int type
– PRADIP KUMAR
Nov 21 '18 at 11:17
int SliderType = [sampleDict[@"SliderType"] integerValue];
– PRADIP KUMAR
Nov 21 '18 at 11:20
|
show 1 more comment
I have added code in swift lang .. You can take reference and apply same logic there. It will work
let ImagesArray = [
[
"SliderID" : 1,
"SliderType" : 1,
"SliderURL" : "http://mca.bananaappscenter.com/Images/SliderImages/MaskGroup2.png",
"Status" : 1
],
[
"SliderID" : 2,
"SliderType" : 1,
"SliderURL" : "http://mca.bananaappscenter.com/Images/SliderImages/MaskGroup3.png",
"Status" : 1
],
[
"SliderID" : 3,
"SliderType" : 2,
"SliderURL" : "https://www.youtube.com/watch?v=l1yN0KUHgoc",
"Status" : 1
]
]
In tableview cellforrow u can implement like this :
let sampleDict = ImagesArray[indexPath.row] as? NSDictionary
let SliderURL = sampleDict.valueForkey("SliderURL") as? String
let SliderType = sampleDict.objectForkey("SliderType") as? NSNumber
if SliderURL != nil{
//means url abvl
if SliderType == 2{
//video data
cell.addImageView.image = "set video default thumbnail image "
}else if SliderType == 1{
//imagedata
// cell.addImageView.image = "set ur image "
}
}
In Objective C
NSMutableDictionary *sampleDict = [ImagesArray objectAtIndex:indexPath.row];
NSString *imageStr = [[NSString alloc]init];
imageStr = [sampleDict valueForKey:@"SliderURL"];
// NSString * SliderType = [[NSString alloc]init];
// SliderType = [sampleDict valueForKey:@"SliderType"];
int SliderType = [[sampleDict valueForKey:@"SliderType"] integerValue];
NSLog(@"%i", SliderType);
if(imageStr != nil)
{
//if([SliderType isEqualToString:@"2"]
if [SliderType isEqualToNumber:[NSNumber numberWithInt:2]] {
cell.addImageView.image = [UIImage imageNamed:@"default"];
}else if [SliderType isEqualToNumber:[NSNumber numberWithInt:1]] {
[cell.addImageView sd_setImageWithURL:[NSURL URLWithString:imageStr]
placeholderImage:[UIImage imageNamed:@"default"]];`
}else{
//nothng
}
}
else
{
//SliderURL is nil
}
I have added code in swift lang .. You can take reference and apply same logic there. It will work
let ImagesArray = [
[
"SliderID" : 1,
"SliderType" : 1,
"SliderURL" : "http://mca.bananaappscenter.com/Images/SliderImages/MaskGroup2.png",
"Status" : 1
],
[
"SliderID" : 2,
"SliderType" : 1,
"SliderURL" : "http://mca.bananaappscenter.com/Images/SliderImages/MaskGroup3.png",
"Status" : 1
],
[
"SliderID" : 3,
"SliderType" : 2,
"SliderURL" : "https://www.youtube.com/watch?v=l1yN0KUHgoc",
"Status" : 1
]
]
In tableview cellforrow u can implement like this :
let sampleDict = ImagesArray[indexPath.row] as? NSDictionary
let SliderURL = sampleDict.valueForkey("SliderURL") as? String
let SliderType = sampleDict.objectForkey("SliderType") as? NSNumber
if SliderURL != nil{
//means url abvl
if SliderType == 2{
//video data
cell.addImageView.image = "set video default thumbnail image "
}else if SliderType == 1{
//imagedata
// cell.addImageView.image = "set ur image "
}
}
In Objective C
NSMutableDictionary *sampleDict = [ImagesArray objectAtIndex:indexPath.row];
NSString *imageStr = [[NSString alloc]init];
imageStr = [sampleDict valueForKey:@"SliderURL"];
// NSString * SliderType = [[NSString alloc]init];
// SliderType = [sampleDict valueForKey:@"SliderType"];
int SliderType = [[sampleDict valueForKey:@"SliderType"] integerValue];
NSLog(@"%i", SliderType);
if(imageStr != nil)
{
//if([SliderType isEqualToString:@"2"]
if [SliderType isEqualToNumber:[NSNumber numberWithInt:2]] {
cell.addImageView.image = [UIImage imageNamed:@"default"];
}else if [SliderType isEqualToNumber:[NSNumber numberWithInt:1]] {
[cell.addImageView sd_setImageWithURL:[NSURL URLWithString:imageStr]
placeholderImage:[UIImage imageNamed:@"default"]];`
}else{
//nothng
}
}
else
{
//SliderURL is nil
}
edited Nov 21 '18 at 11:25
answered Nov 21 '18 at 9:44
PRADIP KUMARPRADIP KUMAR
2291424
2291424
can you please update in objective c
– santoshi
Nov 21 '18 at 9:47
code edited apply it .. @santoshi
– PRADIP KUMAR
Nov 21 '18 at 9:57
error coming invalid argument NCSFNUMBEr
– santoshi
Nov 21 '18 at 10:37
your SliderType data is of number type.. first fetch in number/Int type
– PRADIP KUMAR
Nov 21 '18 at 11:17
int SliderType = [sampleDict[@"SliderType"] integerValue];
– PRADIP KUMAR
Nov 21 '18 at 11:20
|
show 1 more comment
can you please update in objective c
– santoshi
Nov 21 '18 at 9:47
code edited apply it .. @santoshi
– PRADIP KUMAR
Nov 21 '18 at 9:57
error coming invalid argument NCSFNUMBEr
– santoshi
Nov 21 '18 at 10:37
your SliderType data is of number type.. first fetch in number/Int type
– PRADIP KUMAR
Nov 21 '18 at 11:17
int SliderType = [sampleDict[@"SliderType"] integerValue];
– PRADIP KUMAR
Nov 21 '18 at 11:20
can you please update in objective c
– santoshi
Nov 21 '18 at 9:47
can you please update in objective c
– santoshi
Nov 21 '18 at 9:47
code edited apply it .. @santoshi
– PRADIP KUMAR
Nov 21 '18 at 9:57
code edited apply it .. @santoshi
– PRADIP KUMAR
Nov 21 '18 at 9:57
error coming invalid argument NCSFNUMBEr
– santoshi
Nov 21 '18 at 10:37
error coming invalid argument NCSFNUMBEr
– santoshi
Nov 21 '18 at 10:37
your SliderType data is of number type.. first fetch in number/Int type
– PRADIP KUMAR
Nov 21 '18 at 11:17
your SliderType data is of number type.. first fetch in number/Int type
– PRADIP KUMAR
Nov 21 '18 at 11:17
int SliderType = [sampleDict[@"SliderType"] integerValue];
– PRADIP KUMAR
Nov 21 '18 at 11:20
int SliderType = [sampleDict[@"SliderType"] integerValue];
– PRADIP KUMAR
Nov 21 '18 at 11:20
|
show 1 more comment
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53407029%2fhow-to-do-json-type-response%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
plz add additional code
– Anbu.Karthik
Nov 21 '18 at 7:22
if(requestType == RequestTypeHomeSlider) { NSLog(@"%@",responseObject); NSString *respCode =[NSString stringWithFormat:@"%@", [responseDict valueForKey:@"StatusCode"]]; if([respCode isEqualToString:@"200"]) { ImagesArray= [NSMutableArray new]; ImagesArray = [responseObject valueForKey:@"SliderList"]; [_imageCollectionView reloadData]; }
– santoshi
Nov 21 '18 at 7:25
plz add additional code
– Anbu.Karthik
Nov 21 '18 at 7:26
Hi @karthik which code you want? please tell me
– santoshi
Nov 21 '18 at 7:27
related to your collectionview code or add entire class code in your question
– Anbu.Karthik
Nov 21 '18 at 7:28