- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是我的 JSON 数据,
{
"total": 60,
"per_page": 10,
"current_page": 1,
"last_page": 6,
"next_page_url": "http://www.ladybirdweb.com/support/api/v1/helpdesk/inbox?page=2",
"prev_page_url": null,
"from": 1,
"to": 10,
"data": [
{
"updated_at": "2017-07-18 07:17:25",
"user_name": "eugene@smartitfirm.com",
"first_name": "Eugene",
"last_name": "Dunayev",
"email": "eugene@smartitfirm.com",
"profile_pic": "https://secure.gravatar.com/avatar/841369e30f04310b23750abbb670c65c?s=80&r=g&d=identicon",
"ticket_number": "AAAA-0000-745",
"id": 4395,
"title": "Demo",
"created_at": "2017-07-12 04:15:15",
"department_name": "Support",
"priotity_name": "Low",
"priority_color": "#00a65a",
"sla_plan_name": "Low",
"help_topic_name": "Support query",
"ticket_status_name": "Open",
"department_id": "3",
"user_dpt": null,
"attachment": "23",
"overdue_date": "2017-07-12 12:15:15"
},
{
"updated_at": "2017-07-18 07:15:40",
"user_name": "rmuller@idagroup.net",
"first_name": "Robin",
"last_name": "W.",
"email": "rmuller@idagroup.net",
"profile_pic": "https://secure.gravatar.com/avatar/90efb0e570dfc699f78c414449cb46d9?s=80&r=g&d=identicon",
"ticket_number": "AAAA-0000-776",
"id": 4426,
"title": "=?UTF-8?Q?Re:_Robin_-_Implementing_Faveo_H?= =?UTF-8?Q?elp_Desk._Let=E2=80=99s_get_you_started.?=",
"created_at": "2017-07-14 16:15:17",
"department_name": "Support",
"priotity_name": "Low",
"priority_color": "#00a65a",
"sla_plan_name": "Low",
"help_topic_name": "Support query",
"ticket_status_name": "Open",
"department_id": "3",
"user_dpt": null,
"attachment": "3",
"overdue_date": "2017-07-17 12:00:00"
}
]
"title: Re: Robin - Implementing Faveo Help Desk. Let’s get you started."
-(void)reload
{
NSString *url=[NSString stringWithFormat:@"%@helpdesk/inbox?api_key=%@&ip=%@&token=%@",[userDefaults objectForKey:@"companyURL"],API_KEY,IP,[userDefaults objectForKey:@"token"]];
MyWebservices *webservices=[MyWebservices sharedInstance];
[webservices httpResponseGET:url parameter:@"" callbackHandler:^(NSError *error,id json,NSString* msg) {
if (error || [msg containsString:@"Error"]) {
[refresh endRefreshing];
[[AppDelegate sharedAppdelegate] hideProgressView];
if (msg) {
[utils showAlertWithMessage:[NSString stringWithFormat:@"Error-%@",msg] sendViewController:self];
}else if(error) {
[utils showAlertWithMessage:[NSString stringWithFormat:@"Error-%@",error.localizedDescription] sendViewController:self];
NSLog(@"Thread-NO4-getInbox-Refresh-error == %@",error.localizedDescription);
}
return ;
}
if ([msg isEqualToString:@"tokenRefreshed"]) {
[self reload];
NSLog(@"Thread--NO4-call-getInbox");
return;
}
if (json) {
//NSError *error;
NSLog(@"Thread-NO4--getInboxAPI--%@",json);
_mutableArray = [json objectForKey:@"data"];
_nextPageUrl =[json objectForKey:@"next_page_url"];
_currentPage=[[json objectForKey:@"current_page"] integerValue];
_totalTickets=[[json objectForKey:@"total"] integerValue];
_totalPages=[[json objectForKey:@"last_page"] integerValue];
NSLog(@"Thread-NO4.1getInbox-dic--%@", _mutableArray);
dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
dispatch_async(dispatch_get_main_queue(), ^{
[[AppDelegate sharedAppdelegate] hideProgressView];
[refresh endRefreshing];
[self.tableView reloadData];
});
});
}
NSLog(@"Thread-NO5-getInbox-closed");
}];
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.row == [_mutableArray count]) {
LoadingTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"LoadingCellID"];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"LoadingTableViewCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
UIActivityIndicatorView *activityIndicator = (UIActivityIndicatorView *)[cell.contentView viewWithTag:1];
[activityIndicator startAnimating];
return cell;
}else{
TicketTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"TableViewCellID"];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"TicketTableViewCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
NSDictionary *finaldic=[_mutableArray objectAtIndex:indexPath.row];
cell.ticketIdLabel.text=[finaldic objectForKey:@"ticket_number"];
NSString *fname= [finaldic objectForKey:@"first_name"];
NSString *lname= [finaldic objectForKey:@"last_name"];
NSString *userName= [finaldic objectForKey:@"user_name"];
[Utils isEmpty:fname];
[Utils isEmpty:lname];
if (![Utils isEmpty:fname] && ![Utils isEmpty:lname])
{
cell.mailIdLabel.text=[NSString stringWithFormat:@"%@ %@",[finaldic objectForKey:@"first_name"],[finaldic objectForKey:@"last_name"]];
}
else
{ if(![Utils isEmpty:userName])
{
cell.mailIdLabel.text=[finaldic objectForKey:@"user_name"];
}
else
{
cell.mailIdLabel.text=[finaldic objectForKey:@"email"];
}
}
NSString *title1= [finaldic objectForKey:@"title"];
[Utils isEmpty:title1];
if ([Utils isEmpty:title1]){
cell.ticketSubLabel.text=@"No Title";
}
else
{
cell.ticketSubLabel.text=[finaldic objectForKey:@"title"];
}
return cell;
}
-(void)httpResponseGET:(NSString *)urlString
parameter:(id)parameter
callbackHandler:(callbackHandler)block{
NSError *error;
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:urlString]];
//[request addValue:@"text/html" forHTTPHeaderField:@"Accept"];
[request addValue:@"application/json" forHTTPHeaderField:@"Accept"];
[request addValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setTimeoutInterval:45.0];
NSData *postData = nil;
if ([parameter isKindOfClass:[NSString class]]) {
postData = [((NSString *)parameter) dataUsingEncoding:NSUTF8StringEncoding];
} else {
postData = [NSJSONSerialization dataWithJSONObject:parameter options:0 error:&error];
}
[request setHTTPBody:postData];
[request setHTTPMethod:@"GET"];
NSLog(@"Thread--httpResponseGET--Request : %@", urlString);
NSURLSession *session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration] ];
[[session dataTaskWithRequest:request completionHandler:^(NSData * data, NSURLResponse * response, NSError * error) {
NSLog(@"Response is required : %@",(NSHTTPURLResponse *) response);
if (error) {
dispatch_async(dispatch_get_main_queue(), ^{
block(error,nil,nil);
});
NSLog(@"Thread--httpResponseGET--dataTaskWithRequest error: %@", [error localizedDescription]);
}else if ([response isKindOfClass:[NSHTTPURLResponse class]]) {
NSInteger statusCode = [(NSHTTPURLResponse *)response statusCode];
if (statusCode != 200) {
NSLog(@"dataTaskWithRequest HTTP status code: %ld", (long)statusCode);
if (statusCode==400) {
if ([[self refreshToken] isEqualToString:@"tokenRefreshed"]) {
dispatch_async(dispatch_get_main_queue(), ^{
block(nil,nil,@"tokenRefreshed");
});
NSLog(@"Thread--httpResponsePOST--tokenRefreshed");
}else {
dispatch_async(dispatch_get_main_queue(), ^{
block(nil,nil,@"tokenNotRefreshed");
});
NSLog(@"Thread--httpResponsePOST--tokenNotRefreshed");
}
}else
dispatch_async(dispatch_get_main_queue(), ^{
block(nil, nil,[NSString stringWithFormat:@"Error-%ld",(long)statusCode]);
});
return ;
}
NSString *replyStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
if ([replyStr containsString:@"token_expired"]) {
NSLog(@"Thread--httpResponseGET--token_expired");
if ([[self refreshToken] isEqualToString:@"tokenRefreshed"]) {
dispatch_async(dispatch_get_main_queue(), ^{
block(nil,nil,@"tokenRefreshed");
});
NSLog(@"Thread--httpResponseGET--tokenRefreshed");
}else {
dispatch_async(dispatch_get_main_queue(), ^{
block(nil,nil,@"tokenNotRefreshed");
});
NSLog(@"Thread--httpResponseGET--tokenNotRefreshed");
}
return;
}
NSError *jsonerror = nil;
id responseData = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&jsonerror];
dispatch_async(dispatch_get_main_queue(), ^{
block(jsonerror,responseData,nil);
});
}
}] resume];
}
最佳答案
检查以下代码,我希望它会工作。我根据你的代码创建..!此代码取自@Sophy Swicz。
NSString *encodedString =[finaldic objectForKey:@"title"];
[Utils isEmpty:encodedString];
if ([Utils isEmpty:encodedString]){
cell.ticketSubLabel.text=@"No Title";
}
else
{
NSMutableString *decodedString = [[NSMutableString alloc] init];
if ([encodedString hasPrefix:@"=?UTF-8?Q?"] || [encodedString hasSuffix:@"?="])
{
NSScanner *scanner = [NSScanner scannerWithString:encodedString];
NSString *buf = nil;
// NSMutableString *decodedString = [[NSMutableString alloc] init];
while ([scanner scanString:@"=?UTF-8?Q?" intoString:NULL]
|| ([scanner scanUpToString:@"=?UTF-8?Q?" intoString:&buf] && [scanner scanString:@"=?UTF-8?Q?" intoString:NULL])) {
if (buf != nil) {
[decodedString appendString:buf];
}
buf = nil;
NSString *encodedRange;
if (![scanner scanUpToString:@"?=" intoString:&encodedRange]) {
break; // Invalid encoding
}
[scanner scanString:@"?=" intoString:NULL]; // Skip the terminating "?="
// Decode the encoded portion (naively using UTF-8 and assuming it really is Q encoded)
// I'm doing this really naively, but it should work
// Firstly I'm encoding % signs so I can cheat and turn this into a URL-encoded string, which NSString can decode
encodedRange = [encodedRange stringByReplacingOccurrencesOfString:@"%" withString:@"=25"];
// Turn this into a URL-encoded string
encodedRange = [encodedRange stringByReplacingOccurrencesOfString:@"=" withString:@"%"];
// Remove the underscores
encodedRange = [encodedRange stringByReplacingOccurrencesOfString:@"_" withString:@" "];
// [decodedString appendString:[encodedRange stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSString *str1= [encodedRange stringByRemovingPercentEncoding];
[decodedString appendString:str1];
}
NSLog(@"Decoded string = %@", decodedString);
cell.ticketSubLabel.text= decodedString;
}
else{
cell.ticketSubLabel.text= encodedString;
}
}
关于ios - 在 JSON 中,我在 "title"中获取以下格式的数据,如何获取实际数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45159711/
有什么方法可以覆盖无法直接编辑的页面标题,只能在页眉中添加 Javascript? 我不能直接编辑的行是: Title of the page 我能想到的解决这个问题的唯一方法是在我可以通过我的门户后
这是我的基础文件 {% load static %} {% include "feed/header.html" %} {% block content%} {% endblock %} {% inc
请说明 之间有什么区别标记和 标签。 Page title 如果两者都使用,哪个最优先? 我观察到一些网站同时具有 和 tags 和 两者相同,这是预期的,请确认? 如果我们不使用 标签标题,我
我有一个带有唯一title的表_primary,并且我有一个需要设置引用title的表_secondary > 对于 _primary 表。 最佳答案 尝试这个解决方案并让我知道它对您有用。 ALTE
我正在尝试学习使用 PDO 而不是 MySQLi 进行数据库访问,但我在从数据库中选择数据时遇到了问题。我想使用: $STH = $DBH->query('SELECT * FROM ratings
我了解 title 和 alt 属性的用途,但我只是不了解它们的最佳用途,或者我是否可以使用相同的 title /alt 不止一次。 例如,以一个关于狗的网站为例: 根据我的理解,所有 img 标签都
我分配了一个带有标题 (initWithTitle) 的 UITabBarItem 并将其连接到 UINavigationController。 我发现,如果导航 Controller 的 Root
我有标签栏和导航栏。在导航栏中我有表格 View 。问题是,当我在 IB 中将标题设置为选项卡栏,然后在 TableView 中设置标题时,选项卡栏标题将更改为 TableView 中的标题,并且我在
在我的 JSP 页面中,我使用 显示页面标题,有时可以,但有时页面显示无法cpmplie代码 。所以我将代码更改为 ${TITLE} ,也可以。 有什么不同和${TITLE}在jsp中? 这是我的页
我目前正在向 Jade 和 node.js 介绍自己 由于我想避免冗余,我想到将域名附加到当前标题,例如Blog | example.com 我的 Jade 模板得到了 Blog通过 Node.js
//Sorting userDefined object from ArrayList<>... import java.io.*; import java.util.*; class Song
我的网站有这两个元标记,它们目前具有相同的值: 第二个是 facebook 连接所需的格式。 这是否意味着第一个是多余的并且可以删除? 最佳答案 最好同时存在这两个标签。该标签告诉搜索引擎有
我现在对 ASP.NET MVC 的 Razor ViewEngine 感到困惑。 大多数人会说: View.Title 与相同 ViewData["Title"] 运行应用程序后我得到了这个 Com
UIViewController 的 title 属性的用途是什么,不能用 navigationItem.title 设置标题吗? 两者似乎都有效,我只是想知道为什么会有这种看似重复的功能。 最佳答案
我仍在学习如何将 API 数据与 react 和 nextjs 一起使用。但是,为什么我的函数只在我编写 {props.props.title} 而不是我期望的 {props.title} 时起作用?
我正在尝试编写一个从URL提取的正则表达式,但是问题是“。”与我们已经知道的不匹配换行符。如何编写正则表达式以匹配和提取pageTitle(。*?),但换行符可能介于 我在用grails。 最佳答案
我仍在学习如何将 API 数据与 react 和 nextjs 一起使用。但是,为什么我的函数只在我编写 {props.props.title} 而不是我期望的 {props.title} 时起作用?
我正在 github 上创建一个库,所以我为此使用了一个 Markdown 文件,其结构如下: # My main title ## My first section ... ## My second
我在某些地方看到,为了从 props 中获取 title 的值,我们使用 {`${props.title} `} 而在其他一些地方,我们使用它 {props.title} 有什么区别? 最佳答案 第一
我想使用 IMG 标签的 TITLE 属性,为图像创建标题: HTML CSS img[title]:after{content:attr(title);} 但是无论是在 IE、Firefox 还是
我是一名优秀的程序员,十分优秀!