小编Nim*_*sri的帖子

用于实现市场或应用商店的Opensource或库

我将实现一个基于网络的数字内容市场.不知何故,它的功能类似于应用程序商店,其中销售商品是应用程序,但我的市场目标是数字内容.在我开始从头开始实施一切之前,我想确保我不会重新发明一些轮子.欢迎任何推荐的工具或个人经验.可伸缩性是我工具采用的主要关注点.

open-source scalability

6
推荐指数
1
解决办法
4143
查看次数

退还以前购买的非续订订阅,而不是当前订阅.可能?

我正在实施一个不续订的iOS应用程序.网上没有太多相关信息; 所以我寻求你的指导.

最让我担心的用例是用户购买订阅一次,然后再次购买后立即延长服务期限(请参见此处的情况).如果该用户退还第一次购买,第二次购买完好无损怎么办?这在实践中甚至是可能的,还是我太偏执了?

假设上述情况可能,我的应用程序将遇到问题,因为据我所知,verifyReceipt只返回最新的好收据(Managing Subscriptions with In-App Purchase在WWDC'12中观看).

我发现Apple无处提供有关退款政策的相关信息.

(自动更新订阅似乎排除了这种情况,因为iTunes自动处理更新操作,并且在iTunes允许之前似乎无法扩展此类订阅.)

in-app-purchase ios receipt auto-renewing

6
推荐指数
1
解决办法
1113
查看次数

取消与UITableViewCells关联的NSTimers,当它们离开屏幕时

我实现UITableViewUIImageView细胞,其中的每一个通过周期性地刷新本身每5秒NSTimer.每个图像都是从后台线程中的服务器加载的,并且从后台线程我还通过调用更新UI,显示新图像performSelectorOnMainThread.到现在为止还挺好.

我注意到的问题是线程数随着时间的推移而增加,UI变得无响应.因此,我想NSTimer在一个单元格离开屏幕时无效.UITableView我应该使用哪种委派方法来有效地执行此操作?

之所以我将NSTimer每个单元格关联起来是因为我不希望所有单元格同时发生图像转换.顺便说一句,有没有其他方法可以做到这一点?例如,是否可以只使用一个NSTimer

(我无法使用,SDWebImage因为我的要求是在从服务器加载的循环中显示一组图像)

//在MyViewController.m中

 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        ...
        NSTimer* timer=[NSTimer scheduledTimerWithTimeInterval:ANIMATION_SCHEDULED_AT_TIME_INTERVAL 
                                                    target:self 
                                                  selector:@selector(updateImageInBackground:) 
                                                  userInfo:cell.imageView 
                                                   repeats:YES];
        ...
    }

- (void) updateImageInBackground:(NSTimer*)aTimer
{  
    [self performSelectorInBackground:@selector(updateImage:)
                       withObject:[aTimer userInfo]];
}  

- (void) updateImage:(AnimatedImageView*)animatedImageView 
{      
    @autoreleasepool { 
        [animatedImageView refresh];
    }
}  
Run Code Online (Sandbox Code Playgroud)

//在AnimatedImageView.m中

 -(void)refresh
    {
        if(self.currentIndex>=self.urls.count)
            self.currentIndex=0;

    ASIHTTPRequest *request=[[ASIHTTPRequest alloc] initWithURL:[self.urls objectAtIndex:self.currentIndex]];
    [request startSynchronous];

    UIImage *image = [UIImage imageWithData:[request responseData]];

    // How do …
Run Code Online (Sandbox Code Playgroud)

uitableview nstimer ios

5
推荐指数
2
解决办法
2342
查看次数

Core Motion的加速度计在后台模式下实现的奇怪行为

我在iOS上实现了一个计步器.一个重要的要求是,即使应用程序处于后台模式(例如,设备被锁定或用户按下主页按钮),它也必须工作.您可以在App Store中看到这样的实现,如Nike +,Runtastic Pedometer等.

一些SO帖子证实,这可以通过Core Motion实现,或者特别是CMMotionManager具有Required background modes设置为的附加属性location.

我使用下面的代码进行了快速测试,发现了一个奇怪的问题:

// AppDelegate.m
- (void)applicationDidEnterBackground:(UIApplication *)application
{ 
    if(self.motionManager==nil) {
        self.motionManager=[[CMMotionManager alloc] init];
    }
    self.motionManager.accelerometerUpdateInterval=1/50;

    if(self.accelerometerReadings==nil) 
        self.accelerometerReadings=[[NSMutableArray alloc] init];

    [self.motionManager startAccelerometerUpdatesToQueue:[NSOperationQueue mainQueue] withHandler:^(CMAccelerometerData *accelerometerData, NSError *error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [self.accelerometerReadings addObject:accelerometerData];
        });
    }
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    NSLog(@"The number of readings %d",self.accelerometerReadings.count);

    // do something with accelerometer data...
}
Run Code Online (Sandbox Code Playgroud)

我用iPhone 4S和iOS 6.1试过这段代码.当应用程序启动时,我按下主页按钮并摇动它(模拟行走)5秒钟,然后再次打开应用程序.这些动作重复了几次.我得到的输出是:

2013-02-05 16:41:42.028 [1147:907] readings 0
2013-02-05 16:41:51.572 [1147:907] readings 444
2013-02-05 16:42:00.386 [1147:907] readings …
Run Code Online (Sandbox Code Playgroud)

accelerometer background-process ios core-motion cmmotionmanager

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

[NSCFString timeIntervalSinceReferenceDate]:发送到实例的无法识别的选择器

我想比较两个日期之间的差异,但是使用下面的代码我收到错误"[NSCFString timeIntervalSinceReferenceDate]:无法识别的选择器发送到实例." 代码有什么问题?

NSDate *dateAdded=[eventDictionary objectForKey:@"dateAdded"];
NSDate *validUntilDate=[eventDictionary objectForKey:@"validUntilDate"];
NSDateComponents *sometimeAgo = [[NSCalendar currentCalendar] components:(NSSecondCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit) fromDate:dateAdded  toDate:validUntilDate  options:0]; 
Run Code Online (Sandbox Code Playgroud)

nsdate nscalendar nstimeinterval ios

4
推荐指数
1
解决办法
8792
查看次数

iOS应用内购买收据字符串说明

我试图了解从iTunes服务器获得的收据信息,但是找不到相关文档。

特别是,有什么之间的差异unique_identifierunique_vendor_identifieroriginal_transaction_id(这是声称,在WWDC'12会议,是事实上的客户ID)和[[[UIDevice currentDevice] identifierForVendor] UUIDString]

{"receipt":
    {"original_purchase_date_pst":"...",        
     "purchase_date_ms":"...", 
     "unique_identifier":"...", 
     "original_transaction_id":"...", 
     "bvrs":"...", 
     "transaction_id":"...", 
     "quantity":"...", 
     "unique_vendor_identifier":"...", 
     "item_id":"...", 
     "product_id":"...", 
     "purchase_date":"...", 
     "original_purchase_date":"...", 
     "purchase_date_pst":"...", 
     "bid":"...", 
     "original_purchase_date_ms":"..."},  
"status":0}`
Run Code Online (Sandbox Code Playgroud)

我希望将此收据信息存储在我的服务器上以跟踪订阅的有效性。因此,最好知道我应该使用哪个id作为用户身份的替代。

uniqueidentifier in-app-purchase ios receipt

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

在应用商店中抓取数据

有谁知道AppShopper.com如何抓取Apple应用程序商店中的数据?我们是否必须使用像Watir这样的自动化测试来模拟浏览器?这是收集数据的唯一方法(例如,下载统计数据,价格)吗?

iphone indexing web-crawler app-store

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

loadNibNamed与initWithFrame设置框架高度和宽度的困境

我创建了一个与.xib文件关联的UIView子类.这个UIView子类将在UIViewController中使用.在控制器中,我认为我们实例化UIView子类有两种选择:

MyUIView *myView=[[MyUIView alloc] initWithFrame:aRect];
Run Code Online (Sandbox Code Playgroud)

MyUIView *myView = [[[NSBundle mainBundle] loadNibNamed:@"MyUIView" 
                                                  owner:self 
                                                options:nil] lastObject]; 
Run Code Online (Sandbox Code Playgroud)

我更喜欢允许我执行自定义初始化的第一种方法或其变体.唯一的问题是我必须指定一个框架的rect,它已经在中指定了.xib(我的意思是框架的高度和宽度MyUIView).是的,我能再次硬编码aRect,但这是乏味的维护(例如,当我改变的.xib用户界面的位置,我需要更新aRect,太).

所以第二种方法应该在脑架自动设置时考虑到.剩下的问题是我无法自定义初始化程序(比方说,我想在初始化期间传递额外的参数).

你有什么偏好?你认为哪一个更好?

编辑1:受塞尔吉奥的回答启发,我推出了这个解决方法:

// In MyViewController.m
MyUIView *myView=[[MyUIView alloc] initWithFrame:CGRectMake(x, y, 0.0, 0.0)];

// In MyView.m
- (id)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        self = [[[NSBundle mainBundle] loadNibNamed:@"UnmovableTagView" 
                                              owner:self 
                                            options:nil] lastObject]; 
        [self setFrame:CGRectMake(frame.origin.x, 
                                  frame.origin.y, 
                                  [self frame].size.width, 
                                  [self frame].size.height)]; 
        // frame's width and height already determined after 
        // loadNibNamed was called
       ...
    }
    return self; …
Run Code Online (Sandbox Code Playgroud)

uiview designated-initializer ios initwithframe loadnibnamed

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