小编ico*_*ter的帖子

如何在Objective-C中组织API Url

我试图在一个文件中组织我的所有API网址,我正在做的是我创建了一个头文件并添加了以下行

#define LOGIN_URL           @"http://192.168.100.100/api/login"
#define SIGNUP_URL          @"http://192.168.100.100/api/signup"
#define PRODUCTS_URL        @"http://192.168.100.100/api/products"
#define EMPLOYEE_URL        @"http://192.168.100.100/api/employee"
#define GET_PRODUCTS_URL    @"http://192.168.100.100/api/getproducts"
#define CLIENTS_URL         @"http://192.168.100.100/api/clients"
Run Code Online (Sandbox Code Playgroud)

在这里,base url就是http://192.168.100.100/它会不断改变,我总是要查找和替换的IP地址.有没有更好的方法来组织API Url?

api url objective-c code-organization ios

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

在Agda中使用依赖对的问题

我正在通过教程学习Agda,现在我正在阅读依赖对.

所以,这是代码片段:

data ? (A : Set) (B : A ? Set) : Set where
  _,_ : (a : A) ? (b : B a) ? ? A B

infixr 4 _,_

?proj? : {A : Set}{B : A ? Set} ? ? A B ? A
?proj? (a , b) = a

data _?_ {A : Set}(x : A) : List A ? Set where
  first : {xs : List A} ? x ? x …
Run Code Online (Sandbox Code Playgroud)

agda dependent-type

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

如何在iPhone应用程序中打开itunes链接?

我试图在UIControlEventTouchDown按钮按下事件上打开itunes链接.我的代码如下.

    NSString *urlString =@"http://itunes.apple.com/in/album/carnatic-vocal-sanjay-subrahmanyan/id106924807?ign-mpt=uo%3D4";


    NSString *str_ur=[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

    NSURL *url=[NSURL URLWithString:str_ur];

    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
    [webview_buy loadRequest:requestObj];

    webview_buy.delegate=self;

    [self.view addSubview:webview_buy];
Run Code Online (Sandbox Code Playgroud)

这将转到设备中的itunes并打开itunes商店.但我收到一条警告信息

您的请求无法完成.

请用代码提出想法.

iphone itunes objective-c ios4

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

SDWebImage损坏图像

我正在使用SDWebImage(2.7.3框架)并且我收到了损坏的图像,我无法完全理解这个问题.如果是代码(内存......)

(注意:我使用SDWebImage项目而不是框架得到相同的错误.我正在实现"autorelease"和其他类型的内存管理.这个问题出现在设备(iPad)上,但不在模拟器中出现)

在此输入图像描述在此输入图像描述

    __block CALayer *layerCover = [[CALayer alloc] init];
    layerCover.frame = CGRectMake(3, 3, COVER_WIDTH_IPAD_SMALL, COVER_HEIGHT_IPAD_SMALL);
    [btn.layer addSublayer:layerCover];

    [_scroll addSubview:btn];
    [btn release];

    //request or load Vods Images
    [[SDWebImageManager sharedManager] downloadWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@M", vod.cover]]
                                              delegate:self options:SDWebImageProgressiveDownload success:^(UIImage *image, BOOL cached) {
                                                  if (image) {
                                                      layerCover.contents = (id)image.CGImage;
                                                  }
                                                  [layerCover release];
                                              } failure:^(NSError *error) {
                                                  [layerCover release];
                                              }];
Run Code Online (Sandbox Code Playgroud)

//另一种

在此输入图像描述

UIImage * imageTv = [UIImage imageNamed:@"bgDefaultTvImage.png"];
UIImageView * bgTvImage = [[UIImageView alloc] initWithFrame:CGRectMake(startX, 20, imageTv.size.width, imageTv.size.height)];
[bgTvImage setImage:imageTv];

CGFloat sizeWithIcon …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c ipad ios sdwebimage

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

如何在NSOperationQueue完成之前阻止NSOperation?

我有一个数据加载操作需要从主线程运行,以避免潜在的阻塞问题.为此,我使用了NSOperationQueue和NSOperations.

然而,出现的一个问题是存在一种操作以基于传入信息产生附加操作.试图解决这个问题也解决了我在其他地方遇到的一些小问题,因为我遇到的解决方案是给NSOperation它自己的子任务队列.

问题是,只要'main'退出,NSOperation将被标记为'finished',无论子队列是否已完成处理; 我该如何覆盖这种行为?

concurrency objective-c nsoperation nsoperationqueue ios

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

将AVAudioRecorder发送到服务器iOS

我在过去几天尝试将一个本地保存的sounde记录上传到服务器(用一个php文件将其保存到服务器上).问题是我找不到办法做到这一点.

在录制声音(AVAudioRecorder)时,它会保存在"NSTemporaryDirectory()"中:

NSURL *temporaryRecFile = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"VoiceFile"]]];
Run Code Online (Sandbox Code Playgroud)

现在,我检查答案的地方都是使用ASIHTTPRequest.但问题是ios6不支持它.

还有一些其他的库,但无论我尝试什么和如何,没有任何作用.如果有人能帮助我,我会很高兴...

这是我的代码:

ViewController.h

#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
#import <CoreAudio/CoreAudioTypes.h>

@interface ViewController : UIViewController <AVAudioRecorderDelegate,AVAudioPlayerDelegate>
{
    UIButton *recordButton;
    UIButton *playButton;
    UIButton *uploadFile;
    UILabel *recStateLabel;
    BOOL isNotRecording;

    NSURL *temporaryRecFile;
    AVAudioRecorder *recorder;
    AVAudioPlayer *player;
}

@property (nonatomic,retain) IBOutlet UIButton *uploadFile;
@property (nonatomic,retain) IBOutlet UIButton *playButton;
@property (nonatomic,retain) IBOutlet UIButton *recordButton;
@property (nonatomic,retain) IBOutlet UILabel *recStateLabel;

-(IBAction)recording;
-(IBAction)playback;
-(IBAction)upload;

@end
Run Code Online (Sandbox Code Playgroud)

ViewController.m

#import "ViewController.h"
#import <AVFoundation/AVFoundation.h>
#import "STHTTPRequest.h"

@interface ViewController ()

@end

@implementation …
Run Code Online (Sandbox Code Playgroud)

objective-c avaudiorecorder asihttprequest ios afnetworking

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

Sql分组在一年的范围内

这是我的订单

在此输入图像描述

如果我想在每个确切年份都有订单数量,我只需编写此查询

Select COUNT(*) CountOfOrders, Year(OrderDate) Year  
From Orders 
Group by YEAR(OrderDate)
Run Code Online (Sandbox Code Playgroud)

所以有这个结果集

在此输入图像描述

但是,如果我需要这个结果集,该怎么办?

CoundOfOrder       FromYear_toYear
     5            2005-2010
     4            2010-2015
Run Code Online (Sandbox Code Playgroud)

t-sql sql-server

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

C#添加可空小数和优先级?? 操作者

假设一个C#程序具有两个可以为零的十进制属性A和B.以下加法仅返回A的值:var result = A ?? 0 + B ?? 0; 正确的用法是:var result =(A ?? 0)+(B ?? 0);

示例控制台程序:

class Program
{
    static void Main(string[] args)
    {
        A = (decimal)0.11;
        B = (decimal)0.69;

        NullableDecimalAddition();

        Console.ReadLine();
    }

    public static decimal? A { get; set; }
    public static decimal? B { get; set; }

    private static void NullableDecimalAddition()
    {
        decimal result1 = A ?? 0 + B ?? 0;
        decimal result2 = (A ?? 0) + (B ?? 0);
        Console.WriteLine("result1: " + result1); …
Run Code Online (Sandbox Code Playgroud)

c# nullable decimal addition

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

如何访问网页中每个资源的性能对象?

我可以在Chrome开发者工具中看到,为网页中的所有资源加载时间,从服务器获取特定资源所花费的时间以及其他信息.

我想使用JavaScript捕获这些统计信息.这怎么可能?

有window.performance对象可用,但仅适用于请求的页面,不适用于页面资源.有没有办法访问所有页面资源的性能对象.

javascript browser pageload web

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

iOS:确定通知中心是否有通知

我正在处理一个应用程序,需要确定通知中心是否有任何通知(对于此应用程序).我想知道是否有人知道在通知中心访问应用程序通知的方法.

objective-c push-notification apple-push-notifications ios

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