小编Suh*_*til的帖子

当通知超过64的限制时,如何在iOS中安排更多本地通知

我正在开发一个日历应用程序,其中包含多个事件(例如500个事件),其中包括生日.我正在下载事件表单Web服务.我想在生日那天上午10点的特定时间给每个出生日期的用户提醒.我正在使用本地通知来安排警报,但我被困住,因为iOS每个应用程序只允许64个通知,我有多个生日.一旦应用程序超过限制,我不知道如何安排更多通知.请建议我如何解决这个问题.下面是我安排通知的代码

- (void)scheduleNotification:(NSMutableArray *)datesArray withMessage:(NSMutableArray *)messagesArray  NotificationID:(NSString *)notificationID
{

    NSCalendar *calendar = [NSCalendar currentCalendar];

    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
    [formatter setDateStyle:NSDateFormatterNoStyle];
    [formatter setTimeStyle:NSDateFormatterShortStyle];


    NSDateFormatter *formatter1 = [[NSDateFormatter alloc]init];
    [formatter1 setDateStyle:NSDateFormatterMediumStyle];
    [formatter1 setDateFormat:@"dd/MM/yyyy"];

   // NSDate *myTime = [formatter dateFromString:@"06:10 PM"];
    NSDate *myTime = [formatter dateFromString:fireTime];

    for (int i = 0; i < [datesArray count]; i++)
    {
        NSDate *myDate = [formatter1 dateFromString:[datesArray objectAtIndex:i]];

        NSDateComponents *dateComponents = [calendar components:NSDayCalendarUnit|NSMonthCalendarUnit|NSYearCalendarUnit fromDate:myDate];
        NSDateComponents *timeComponents = [calendar components:NSHourCalendarUnit|NSMinuteCalendarUnit fromDate:myTime];

        NSDateComponents * newComponents = [[NSDateComponents alloc]init];
        NSDateComponents …
Run Code Online (Sandbox Code Playgroud)

notifications alert calendar ios uilocalnotification

8
推荐指数
1
解决办法
5300
查看次数

在显示选项卡栏控制器之前启动登录视图

我有一个使用故事板开发的ios5应用程序,当前在初始启动时显示标签栏控制器视图.我想在显示标签栏控制器之前显示登录屏幕.用户将输入他的用户名和密码,然后系统将对用户进行身份验证,然后如果成功,则显示标签栏控制器.

我已经尝试了以下3个选项但没有运气..任何想法?

(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

    // Option 1
    UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
    PointsViewController *firstVC = [[tabBarController viewControllers] objectAtIndex:0];
    UIViewController *loginViewController = [[LoginViewController alloc] init];
    [firstVC.navigationController pushViewController:loginViewController animated:YES];

    // Option 2
    UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
    UIViewController *loginViewController = [[LoginViewController alloc] init];
    [tabBarController presentViewController:loginViewController animated:NO completion:nil];  

    // Option 3
    UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
    UIViewController *loginViewController = [[LoginViewController alloc] init];
    [tabBarController presentModalViewController:loginViewController animated:NO];

    return YES;
}
Run Code Online (Sandbox Code Playgroud)

tabs controller storyboard ios5

7
推荐指数
1
解决办法
6652
查看次数

使用ios 6中的EventKit创建新日历时,"日历没有源"错误

我正在使用ios 6中的eventkit框架开发日历应用程序.我正在尝试使用该[self.store respondsToSelector:@selector(requestAccessToEntityType:completion:)]方法获取权限,并且在获得访问日历的权限后,我尝试使用EKSourceTypeLocal源创建带有标识符的新日历并将事件添加到新创建的日历.我在这里面临的问题是,当我尝试在iPhone 4s中运行应用程序时,它会显示"日历没有来源"的错误,并且它不会保存我的日历,因此没有任何事件被添加到日历中.我不知道我在这里做错了什么.请指导我解决这个问题.

我在下面发布我的代码

   - (void)viewDidLoad
{
    [super viewDidLoad];

    // Do any additional setup after loading the view, typically from a nib.

    NSLog(@"in view did load method");


    // For iOS 6.0 and later
    self.store = [[EKEventStore alloc] init];
    if([self.store respondsToSelector:@selector(requestAccessToEntityType:completion:)]) {

    [self.store requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
        // handle access here
        dispatch_async(dispatch_get_main_queue(), ^{

            if (granted) {

                NSLog(@"permission granted");

                EKCalendar *myCalendar;

                EKSource *myLocalSource = nil;
                for (EKSource *calendarSource in self.store.sources) {
                    if (calendarSource.sourceType …
Run Code Online (Sandbox Code Playgroud)

iphone calendar ios eventkit ios6

5
推荐指数
1
解决办法
4908
查看次数

如何使用Jersey Rest Webservices和Java解析JSON数组

我从iOS客户端获取Json数组,并希望使用Java和jersey以及Gson解析服务器端的Json.我从iOS发送POST方法中的JSON数组.我想使用json但是如何在Java类中保存json数据.这是我的Json数组的结构

{
    "friendList": [
      {"id": 1, "username": "user1", "name":"person1", "friendUsername":"fUser1", "friendName":"fName1"},
      {"id": 2, "username": "user2", "name":"person2", "friendUsername":"fUser2", "friendName":"fName2"},
      {"id": 3, "username": "user3", "name":"person3", "friendUsername":"fUser3", "friendName":"fName3"},...
    ]
}
Run Code Online (Sandbox Code Playgroud)

这是我的Web服务类

@Path("/FriendsList")
public class RestWebServicesAPI {


     @POST
     @Path("/friends")
     @Consumes(MediaType.APPLICATION_JSON)
     public Friends saveFriedList(Friends friend, @Context HttpServletRequest request) {

        // Don't know how to parse json array????

     }


}
Run Code Online (Sandbox Code Playgroud)

这是我的朋友班

import java.util.List; 

import javax.xml.bind.annotation.XmlRootElement; 

@XmlRootElement 

Public Class Friends {

    private String id; 
    private String username; 
    private String name; 
    private String friendUsername; 
    private String friendName;  

    public …
Run Code Online (Sandbox Code Playgroud)

java arrays json web-services jersey

3
推荐指数
1
解决办法
1万
查看次数

如何使用NSLog显示对象数组

使用"NSLog"显示对象数组的解决方案是什么.

我可以用我的TableView显示它:

- (UITableViewCell *)tableView:(UITableView *)tableView
             cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        UITableViewCell *cell = [tableView
                                 dequeueReusableCellWithIdentifier:@"MyBasicCell2"];
        DataOrder *bug = [[[ArrayBuying instance] tableau] objectAtIndex:indexPath.row];
      static NSString *CellIdentifier = @"MyBasicCell2";
        CustomCellFinalView *Cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];


        if (!Cell) {
            Cell = [[CustomCellFinalView alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        }

        Cell.NomProduit.text = bug.product;
        Cell.Quantite.text = [NSString stringWithFormat:@"%.2f €", bug.price];
        Cell.Prix.text = [NSString stringWithFormat:@"X %d  ", bug.quantite];

        return Cell;
        return cell;    
}
Run Code Online (Sandbox Code Playgroud)

当我尝试我的ViewDidLoad:方法时

NSLog(@"%@",[[ArrayBuying instance] tableau]);
Run Code Online (Sandbox Code Playgroud)

我在目标输出中获得:

(
    "<DataOrder: 0x15d5d980>",
    "<DataOrder: 0x15de1aa0>"
)
Run Code Online (Sandbox Code Playgroud)

非常感谢您的未来帮助

arrays object objective-c ios

1
推荐指数
2
解决办法
9970
查看次数