小编Lor*_*o B的帖子

在MagicalRecord中清理(删除)数据库

我有一个使用MagicalRecord进行核心数据处理的应用程序,这很好用.但是,我有不同的用户可以在应用程序中登录,当另一个用户登录时,必须清空核心数据数据库,以便不同的用户可以拥有自己的数据.数据库可以完全清空,因为数据也存储在Web服务上,因此在再次登录第一个用户后可以始终再次同步.

到目前为止,我似乎无法找到一个帮助方法(这是有效的)为此目的.我试过了

[MagicalRecord cleanUp];
Run Code Online (Sandbox Code Playgroud)

每当用户注销时,但这不起作用.

xcode core-data ios magicalrecord

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

如何向UIView添加径向渐变?

我有一个UIView我想要一个径向渐变,我想知道如何去做这个?

objective-c radial-gradients uiview ios

14
推荐指数
4
解决办法
2万
查看次数

将数据与JSON API同步的最有效方法是什么?

将我的Core Data架构与提供JSON的远程API同步的最佳方法是什么?目前,我正在循环查看JSON响应中的每个字典,检查核心数据以查看API ID是否存在.

这很好用,但现在要做的就是删除服务器上没有的任何本地对象.以下是我的JSON数据示例:

[
   {
      "id":1234,
      "name":"My first object",
      "description":"This is a long string with lots of information"
   },
   {
      "id":1235,
      "name":"My second object",
      "description":"This is a long string with lots of information"
   }
]
Run Code Online (Sandbox Code Playgroud)

目前,我能想到实现这一目标的唯一方法如下:

NSArray *jsonData = // Convert json data to array using NSJSONSerialization
NSInteger fetchedCount = _fetchedResultsController.fetchedObjects.count;

if (fetchedCount != jsonData.count) {

    for (int i = 0; i < fetchedCount; i++) {

        NSManagedObject *object = [_fetchedResultsController objectAtIndexPath: [NSIndexPath indexPathForItem:i
                                                                                                    inSection:0]];
        NSNumber *idNumber = object.apiID;

        BOOL …
Run Code Online (Sandbox Code Playgroud)

iphone json core-data ios

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

'NSFetchedResultsController不支持使用NSDictionaryResultType更改跟踪和获取请求'

我有一个在OS3 +下运行得很好的应用程序.但它在OS4下不起作用.我收到以下错误消息:

'NSFetchedResultsController不支持使用NSDictionaryResultType更改跟踪和获取请求'

它对这里的任何人都响了吗?

- (NSFetchedResultsController *)fetchedResultsController {

    if (fetchedResultsController != nil) {
        return fetchedResultsController;
    }

    /*
     Set up the fetched results controller.
     */
    // Create the fetch request for the entity.
    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
    // Edit the entity name as appropriate.
    NSEntityDescription *entity = [NSEntityDescription entityForName:@"myEntity" inManagedObjectContext:managedObjectContext];

    [fetchRequest setEntity:myEntity];

    [fetchRequest setResultType:NSDictionaryResultType];

    [fetchRequest setPropertiesToFetch :[NSArray arrayWithObjects:@"FIELD1",@"FIELD2",@"FIELD3",@"FIELD4",@"FIELD5",nil]];      

    // Setting unique values        
    [fetchRequest setReturnsDistinctResults:YES];       

    // Edit the sort key as appropriate.
    NSSortDescriptor *initialDescriptor = [[NSSortDescriptor alloc] initWithKey:@"FIELD1" ascending:YES];

    NSArray …
Run Code Online (Sandbox Code Playgroud)

iphone core-data nsfetchedresultscontroller ios4

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

在Ajax应用程序中提交表单时隐藏移动safari键盘

我有一个文本字段,可以在Web应用程序中触发事件,但我希望键盘在用户按下回车时关闭.使用jquery禁用常规提交.

iphone jquery jquery-mobile

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

删除最后一条记录时UITableView deleteRowsAtIndexPath崩溃

当我从a中删除最后一条记录时遇到以下错误UITableView.

由于未捕获的异常'NSInternalInconsistencyException'而终止应用程序,原因:'无效更新:第0节中的行数无效.更新后的现有部分中包含的行数(3)必须等于该行中包含的行数在更新(1)之前的部分,加上或减去从该部分插入或删除的行数(插入1个,删除1个)并加上或减去移入或移出该部分的行数(0移入,0移动)出)."

如果表数组为空,我的目标是显示"No Record found".

这是我正在使用的代码.当我从表数组中删除最后一条记录时,应用程序崩溃了.如何重新加载表并显示"No Record Found"标签?

// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if ([idArray count]==0) {
        return  3;
    }
    else 
    {
        return [idArray count];
    }   
}

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    NSLog(@"array count %d",[idArray count]);
    if ([idArray count] == 0) {
        static NSString *CellIdentifier = @"Cell";

        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell …
Run Code Online (Sandbox Code Playgroud)

iphone uitableview ios

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

架构错误的未定义符号

我使用Core Data在表视图中显示数据,但我经常遇到这个问题:

体系结构i386的未定义符号:
"_ OBJC_CLASS _ $ _ NSEntityDescription",引用自:singleViewDelegate.o中的objc-class-ref.在singleViewController.o中的objc-class-ref"_OBJC_CLASS _ $ _ NSFetchRequest",引自:singleViewController中的objc-class-ref. o"_OBJC_CLASS _ $ _ NSFetchedResultsController",引用自:objc-class-ref in singleViewController.o"_ OBJC_METACLASS _ $ _ NSManagedObject",引自:_OBJC_METACLASS _ $ _ Data in Data中的数据"_OBJC_CLASS _ $ _ NSManagedObject",引自:_OBJC_CLASS _ $ _ Data in Data. Ø

这是我的singleViewController.m

#import "Data.h"
#import "singleViewController.h"

@interface singleViewController ()

@end

@implementation singleViewController

@synthesize managedObjectContext;
@synthesize fetchedResultsController = _fetchedResultsController;

- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super …
Run Code Online (Sandbox Code Playgroud)

iphone core-data ios

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

使用ARC的iOS应用程序,查找谁是对象的所有者

我正在编写一个使用ARC的应用程序,目前似乎有一些内存泄漏.谷歌搜索我发现了一些关于如何使用Inspector的提示.在那里,我可以看到一些类的实例分配的大量,我也可以看到一些调用堆栈关于如何分配对象以及如何更改保留计数.

但似乎我看不到完整的调用堆栈,所以我不知道最终谁拥有该对象.在我看来,这个所有者不知何故不释放对象(或拥有可疑对象的对象).

任何人都可以给我一个关于找到分配对象的所有者的提示吗?

另请注意,对象未标记为"已泄露"但已分配.对我来说,似乎是对象被泄漏,因为分配了稳定的新对象.

有关如何最好地进行和发现可疑泄漏的任何进一步帮助表示赞赏.

memory memory-leaks ios automatic-ref-counting

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

NSDictionary和核心数据

请我尝试获取核心数据方面的一些知识.到目前为止,我已经掌握了创建实体以及添加,检索和删除此实体的值的问题.

我的问题如下.NSDictionary使用核心数据时,在实体中存储属性的可能方法是什么?

core-data nsdictionary iphonecoredatarecipes ios

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

如何在UINavigationController的RootViewController上显示后退按钮?

这是我的代码.我想在开放的rootviewController上放一个后退按钮.

- (void)selectSurah:(id)sender {

    SurahTableViewController * surahTableViewController = [[SurahTableViewController alloc] initWithNibName:@"SurahTableViewController" bundle:nil];
    surahTableViewController.navigationItem.title=@"Surah";

    surahTableViewController.navigationItem.backBarButtonItem.title=@"Back";

    UINavigationController *aNavigationController = [[UINavigationController alloc] initWithRootViewController:surahTableViewController];

    [self presentModalViewController:aNavigationController animated:YES];   
}
Run Code Online (Sandbox Code Playgroud)

iphone xcode uinavigationcontroller uibarbuttonitem ios

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